Module: Orange::Inflector

Extended by:
Inflector
Included in:
Inflector
Defined in:
lib/orange-core/magick.rb

Instance Method Summary collapse

Instance Method Details

#camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true) ⇒ Object



185
186
187
188
189
190
191
# File 'lib/orange-core/magick.rb', line 185

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:



205
206
207
208
209
210
211
212
213
214
# File 'lib/orange-core/magick.rb', line 205

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