Module: RPath::Util
- Defined in:
- lib/rpath/util.rb
Class Method Summary collapse
- .camelcase(string) ⇒ Object
- .first_defined_const(module_, *consts) ⇒ Object
- .underscore(string) ⇒ Object
Class Method Details
.camelcase(string) ⇒ Object
10 11 12 |
# File 'lib/rpath/util.rb', line 10 def camelcase(string) string.gsub(/(?:^|_)([a-z])/) { $1.upcase } end |
.first_defined_const(module_, *consts) ⇒ Object
14 15 16 17 |
# File 'lib/rpath/util.rb', line 14 def first_defined_const(module_, *consts) const = consts.find { |c| module_.const_defined?(c) } const && module_.const_get(const) end |
.underscore(string) ⇒ Object
6 7 8 |
# File 'lib/rpath/util.rb', line 6 def underscore(string) string.gsub(/([^A-Z])([A-Z])/, '\1_\2').downcase end |