module Postmark::Inflector
Public Instance Methods
camel_case_regexp()
click to toggle source
# File lib/postmark/inflector.rb, line 14 def camel_case_regexp /(?:[A-Z](?:(?:[A-Z]+(?![a-z\d]))|[a-z\d]*))|[a-z\d\_]+/ end
to_postmark(name)
click to toggle source
# File lib/postmark/inflector.rb, line 6 def to_postmark(name) name.to_s.split('_').map { |part| capitalize_first_letter(part) }.join('') end
to_ruby(name)
click to toggle source
# File lib/postmark/inflector.rb, line 10 def to_ruby(name) name.to_s.scan(camel_case_regexp).join('_').downcase.to_sym end
Protected Instance Methods
capitalize_first_letter(str)
click to toggle source
# File lib/postmark/inflector.rb, line 20 def capitalize_first_letter(str) if str.length > 0 str.slice(0..0).capitalize + str.slice(1..-1) else str end end