Sha256: 9a94dcfc9c06c612b3b543366fbb6dc67b38cb14a71079abef67e7f726780d82

Contents?: true

Size: 522 Bytes

Versions: 3

Compression:

Stored size: 522 Bytes

Contents

require "active_support/inflector"

module StringHelpers
  def self.underscore_to_classname(underscored_symbol)
    underscored_symbol.to_s.camelize
  end

  def self.classname_to_underscore(classname)
    classname.underscore
  end

  # Lifted from Rails' text helpers.
  def self.pluralize(count, singular, plural_arg = nil, plural: plural_arg)
    word =
      if count == 1 || count.to_s =~ /^1(\.0+)?$/
        singular
      else
        plural || singular.pluralize
      end

    "#{count || 0} #{word}"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
socrates-0.1.26 lib/socrates/string_helpers.rb
socrates-0.1.25 lib/socrates/string_helpers.rb
socrates-0.1.24 lib/socrates/string_helpers.rb