Class: SirTracksAlot::Queue::QueueHelper
- Inherits:
-
Object
- Object
- SirTracksAlot::Queue::QueueHelper
- Defined in:
- lib/sir_tracks_alot/queue/queue_helper.rb
Class Method Summary collapse
- .camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true) ⇒ Object
- .constantize(camel_cased_word) ⇒ Object
Class Method Details
.camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/sir_tracks_alot/queue/queue_helper.rb', line 4 def self.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.first.downcase + camelize(lower_case_and_underscored_word)[1..-1] end end |
.constantize(camel_cased_word) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sir_tracks_alot/queue/queue_helper.rb', line 12 def self.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 |