module ReferenceBook::Inflector
Constants
- CAMEL_REGEX
Public Class Methods
constantize(raw)
click to toggle source
# 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)
click to toggle source
# 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
Private Class Methods
camel_to_snake(raw)
click to toggle source
# File lib/reference_book/inflector.rb, line 29 def camel_to_snake(raw) raw.gsub(CAMEL_REGEX, '\1_\2').downcase end