Class: String

Inherits:
Object show all
Defined in:
lib/betterific/ruby_extensions.rb

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

Return true if self has length 0 or is only whitespace, false otherwise.

This is defined only if it is not yet defined.

Returns:

  • (Boolean)


20
21
22
# File 'lib/betterific/ruby_extensions.rb', line 20

def blank?
  self.strip.size == 0
end

#camelizeObject

Return a camel-case version of self, in contrast to underscore.

This is defined only if it is not yet defined.



32
33
34
# File 'lib/betterific/ruby_extensions.rb', line 32

def camelize
  self.split('_').each(&:capitalize!).join
end

#underscoreObject

Return an underscore version of self, in contrast to camel-case.

This is defined only if it is not yet defined.



41
42
43
# File 'lib/betterific/ruby_extensions.rb', line 41

def underscore
  self.scan(/[A-Z][a-z]*/).join('_').downcase
end