Module: StringHelper

Defined in:
lib/string_helper.rb

Class Method Summary collapse

Class Method Details

.is_i?(word) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/string_helper.rb', line 10

def self.is_i?(word)
  /\A[-+]?\d+\z/ === word
end

.normalize(word) ⇒ Object



6
7
8
# File 'lib/string_helper.rb', line 6

def self.normalize(word)
  underscore(word.sub(/_attributes/, ''))
end

.underscore(word) ⇒ Object



2
3
4
# File 'lib/string_helper.rb', line 2

def self.underscore(word)
  word.split(/(?=[A-Z])/).each { |str| str.downcase! }.join("_")
end