Module: CompaniesHouseGateway::Util

Extended by:
Util
Included in:
Util
Defined in:
lib/companies_house_gateway/util.rb

Instance Method Summary collapse

Instance Method Details

#camelize(str) ⇒ Object

String helper



5
6
7
# File 'lib/companies_house_gateway/util.rb', line 5

def camelize(str)
  str.to_s.split('_').map(&:capitalize).join
end

#demodulize(str) ⇒ Object



16
17
18
# File 'lib/companies_house_gateway/util.rb', line 16

def demodulize(str)
  str.to_s.split('::').last
end

#underscore(str) ⇒ Object



9
10
11
12
13
14
# File 'lib/companies_house_gateway/util.rb', line 9

def underscore(str)
  str.to_s.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').
    tr("-", "_").
    downcase
end