class String

Public Instance Methods

numeric?() click to toggle source
# File lib/string.rb, line 18
def numeric?
  Float(self) != nil rescue false
end
to_camelcase() click to toggle source
# File lib/string.rb, line 2
def to_camelcase
  return self if self !~ /_/ && self =~ /[A-Z]+.*/
  split('_').map{|e| e.capitalize}.join
end
to_camelcase_lower() click to toggle source
# File lib/string.rb, line 7
def to_camelcase_lower
  self.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
end
to_snakecase() click to toggle source
# File lib/string.rb, line 11
def to_snakecase
  return downcase if match(/\A[A-Z]+\z/)
  gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
      gsub(/([a-z])([A-Z])/, '\1_\2').
      downcase
end