Class: Util

Inherits:
Object
  • Object
show all
Defined in:
lib/orats/util.rb

Class Method Summary collapse

Class Method Details

.classify(term) ⇒ Object



11
12
13
# File 'lib/orats/util.rb', line 11

def self.classify(term)
  term.split('_').collect(&:capitalize).join
end

.underscore(term) ⇒ Object



2
3
4
5
6
7
8
9
# File 'lib/orats/util.rb', line 2

def self.underscore(term)
  # taken from ActiveSupport
  term.gsub!(/::/, '/')
  term.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
  term.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
  term.tr!('-', '_')
  term.downcase
end