Module: Orange::Inflector
Instance Method Summary collapse
- #camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true) ⇒ Object
-
#constantize(camel_cased_word) ⇒ Object
:nodoc:.
Instance Method Details
#camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true) ⇒ Object
173 174 175 176 177 178 179 |
# File 'lib/orange-core/magick.rb', line 173 def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true) if first_letter_in_uppercase lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } else lower_case_and_underscored_word.to_s[0].chr.downcase + camelize(lower_case_and_underscored_word)[1..-1] end end |
#constantize(camel_cased_word) ⇒ Object
:nodoc:
193 194 195 196 197 198 199 200 201 202 |
# File 'lib/orange-core/magick.rb', line 193 def constantize(camel_cased_word) names = camel_cased_word.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 |