Module: CompaniesHouseInputGateway::Util
- Defined in:
- lib/companies_house_input_gateway/util.rb
Class Method Summary collapse
- .camelize(str) ⇒ Object
- .create_digest(value) ⇒ Object
- .demodulize(str) ⇒ Object
- .underscore(str) ⇒ Object
Class Method Details
.camelize(str) ⇒ Object
9 10 11 |
# File 'lib/companies_house_input_gateway/util.rb', line 9 def camelize(str) str.to_s.split('_').map(&:capitalize).join end |
.create_digest(value) ⇒ Object
24 25 26 |
# File 'lib/companies_house_input_gateway/util.rb', line 24 def create_digest(value) Digest::MD5.hexdigest(value) end |
.demodulize(str) ⇒ Object
20 21 22 |
# File 'lib/companies_house_input_gateway/util.rb', line 20 def demodulize(str) str.to_s.split('::').last end |
.underscore(str) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/companies_house_input_gateway/util.rb', line 13 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 |