Class: String
- Defined in:
- lib/plist4r.rb,
lib/plist4r/mixin/ruby_stdlib.rb,
lib/plist4r/backend/ruby_cocoa.rb
Instance Attribute Summary collapse
-
#blob ⇒ Object
The blob status of this string (set this to true if a binary string).
Instance Method Summary collapse
-
#blob? ⇒ true, false
Returns whether or not
stris a blob. -
#camelcase ⇒ Object
A Camel-ized string.
-
#snake_case ⇒ Object
A snake-cased string.
-
#to_plist ⇒ Plist4r::Plist
Converts a string of plist data into a new Plist4r::Plist object.
-
#undent ⇒ Object
Remove the leading spaces of the first line, and same to all lines of a multiline string.
Instance Attribute Details
#blob ⇒ Object
The blob status of this string (set this to true if a binary string)
176 177 178 |
# File 'lib/plist4r/mixin/ruby_stdlib.rb', line 176 def blob @blob end |
Instance Method Details
#blob? ⇒ true, false
Returns whether or not str is a blob.
180 181 182 |
# File 'lib/plist4r/mixin/ruby_stdlib.rb', line 180 def blob? @blob end |
#camelcase ⇒ Object
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 |
#snake_case ⇒ Object
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 |
#to_plist ⇒ Plist4r::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 |
#undent ⇒ Object
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 |