Class: String
- Defined in:
-
lib/plist4r.rb,
lib/plist4r/mixin/ruby_stdlib.rb,
lib/plist4r/backend/ruby_cocoa.rb
Instance Methods
Instance Attributes
-
- (Object) blob
The blob status of this string (set this to true if a binary string).
Instance Method Details
- (true, false) blob?
Returns whether or not str is a blob.
180 181 182 |
# File 'lib/plist4r/mixin/ruby_stdlib.rb', line 180 def blob? @blob end |
- (Object) camelcase
A Camel-ized string. The reverse of #snake_case
201 202 203 204 |
# File 'lib/plist4r/mixin/ruby_stdlib.rb', line 201 def camelcase str = self.dup.gsub(/(^|[-_.\s])([a-zA-Z0-9])/) { $2.upcase } \ .gsub('+', 'x') end |
- (Object) snake_case
A snake-cased string. The reverse of #camelcase
209 210 211 212 |
# File 'lib/plist4r/mixin/ruby_stdlib.rb', line 209 def snake_case str = self.dup.gsub(/[A-Z]/) {|s| "_" + s} str = str.downcase.sub(/^\_/, "") end |
- (Plist4r::Plist) to_plist
Converts a string of plist data into a new Plist4r::Plist object
90 91 92 |
# File 'lib/plist4r.rb', line 90 def to_plist return ::Plist4r.new(:from_string => self) end |
- (Object) undent
Remove the leading spaces of the first line, and same to all lines of a multiline string. This effectively shifts all the lines across to the left, until the first line hits the left margin.
194 195 196 |
# File 'lib/plist4r/mixin/ruby_stdlib.rb', line 194 def undent gsub /^.{#{slice(/^ +/).length}}/, '' end |