Sha256: 7afe1aa6b10c5a5b32d7b90020c29227e5fcfbb591c1f2bb5885aa9d655c62c7
Contents?: true
Size: 627 Bytes
Versions: 9
Compression:
Stored size: 627 Bytes
Contents
module DuckPuncher module Ducks module String BOOLEAN_MAP = ::Hash[%w(true 1 yes y on).product([true])].freeze def pluralize(count) "#{self}#{'s' if count != 1}" end unless method_defined?(:pluralize) def underscore gsub(/\B([A-Z])([a-z_0-9])/, '_\1\2').gsub('::', '/').downcase end unless method_defined?(:underscore) def to_boolean !!BOOLEAN_MAP[downcase] end unless method_defined?(:to_boolean) def constantize split('::').inject(Object) { |o, name| o.const_get name } end unless method_defined?(:constantize) end end end
Version data entries
9 entries across 9 versions & 1 rubygems