class String
ripped from rails
Constants
- NON_WHITESPACE_REGEXP
0x3000: fullwidth whitespace
Public Instance Methods
blank?()
click to toggle source
A string is blank if it's empty or contains whitespaces only:
"".blank? # => true " ".blank? # => true " ".blank? # => true " something here ".blank? # => false
# File lib/syncwise_api/ext/core_ext.rb, line 124 def blank? # 1.8 does not takes [:space:] properly if encoding_aware? self !~ /[^[:space:]]/ else self !~ NON_WHITESPACE_REGEXP end end
camelize(first_letter = :upper)
click to toggle source
By default, camelize
converts strings to UpperCamelCase. If the argument to camelize is set to :lower
then camelize produces lowerCamelCase.
camelize
will also convert '/' to '::' which is useful for converting paths to namespaces.
"active_record".camelize # => "ActiveRecord" "active_record".camelize(:lower) # => "activeRecord" "active_record/errors".camelize # => "ActiveRecord::Errors" "active_record/errors".camelize(:lower) # => "activeRecord::Errors"
# File lib/syncwise_api/ext/core_ext.rb, line 151 def camelize(first_letter = :upper) case first_letter when :upper then SyncwiseApi::Inflector.camelize(self, true) when :lower then SyncwiseApi::Inflector.camelize(self, false) end end
Also aliased as: camelcase
dehumanize()
click to toggle source
# File lib/syncwise_api/ext/core_ext.rb, line 133 def dehumanize SyncwiseApi::Inflector.dehumanize(self) end
encoding_aware?()
click to toggle source
# File lib/syncwise_api/ext/string_encoding.rb, line 4 def encoding_aware? true end
underscore()
click to toggle source
# File lib/syncwise_api/ext/core_ext.rb, line 137 def underscore SyncwiseApi::Inflector.underscore(self) end