module DuckPuncher::Ducks::String

Constants

BOOLEAN_MAP

Public Instance Methods

constantize() click to toggle source
# File lib/duck_puncher/ducks/string.rb, line 18
def constantize
  split('::').inject(Object) { |o, name| o.const_get name }
end
pluralize(count) click to toggle source
# File lib/duck_puncher/ducks/string.rb, line 6
def pluralize(count)
  "#{self}#{'s' if count != 1}"
end
to_boolean() click to toggle source
# File lib/duck_puncher/ducks/string.rb, line 14
def to_boolean
  !!BOOLEAN_MAP[downcase]
end
underscore() click to toggle source
# File lib/duck_puncher/ducks/string.rb, line 10
def underscore
  gsub(/\B([A-Z])([a-z_0-9])/, '_\1\2').gsub('::', '/').downcase
end