Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/waffle.rb
Instance Method Summary collapse
Instance Method Details
#camelize ⇒ Object
86 87 88 89 |
# File 'lib/waffle.rb', line 86 def camelize string = sub(/^[a-z\d]*/){$&.capitalize} string.gsub(/(?:_|(\/))([a-z\d]*)/){ "#{$1}#{$2.capitalize}" }.gsub('/', '::') end |
#constantize ⇒ Object
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/waffle.rb', line 75 def constantize names = self.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) end constant end |