Module: TextRazor::Util::ClassMethods
- Defined in:
- lib/textrazor/util.rb
Instance Method Summary collapse
Instance Method Details
#create_from_hash(params) ⇒ Object
24 25 26 27 |
# File 'lib/textrazor/util.rb', line 24 def create_from_hash(params) params = Hash[params.map {|k, v| [standardize(k), v] }] new(params) end |
#standardize(param) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/textrazor/util.rb', line 16 def standardize(param) param.to_s.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end |