Module: ReferenceBook::Inflector

Defined in:
lib/reference_book/inflector.rb

Class Method Summary collapse

Class Method Details

.constantize(raw) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/reference_book/inflector.rb', line 4

def constantize(raw)
  if raw && raw.length > 0
    title = raw.to_s.gsub(/[^a-zA-Z]/, '')
    title[0] = title[0].upcase
    title
  end
end

.make_key(raw) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/reference_book/inflector.rb', line 15

def make_key(raw)
  return nil unless raw
  if raw.is_a? Symbol
    raw
  else
    camel_to_snake(raw.to_s).gsub(/[^a-zA-Z0-9]/, '_').downcase.to_sym
  end
end