Sha256: 560a31220c65b87c4aa928e639b571f5cdf5628da8a5b66b50a88f6f4ead07ff

Contents?: true

Size: 517 Bytes

Versions: 23

Compression:

Stored size: 517 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 =~ /^1(\.0+)?$/
        singular
      else
        plural || singular.pluralize
      end

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

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
socrates-0.1.23 lib/socrates/string_helpers.rb
socrates-0.1.22 lib/socrates/string_helpers.rb
socrates-0.1.21 lib/socrates/string_helpers.rb
socrates-0.1.20 lib/socrates/string_helpers.rb
socrates-0.1.19 lib/socrates/string_helpers.rb
socrates-0.1.18 lib/socrates/string_helpers.rb
socrates-0.1.17 lib/socrates/string_helpers.rb
socrates-0.1.16 lib/socrates/string_helpers.rb
socrates-0.1.15 lib/socrates/string_helpers.rb
socrates-0.1.14 lib/socrates/string_helpers.rb
socrates-0.1.13 lib/socrates/string_helpers.rb
socrates-0.1.12 lib/socrates/string_helpers.rb
socrates-0.1.11 lib/socrates/string_helpers.rb
socrates-0.1.10 lib/socrates/string_helpers.rb
socrates-0.1.9 lib/socrates/string_helpers.rb
socrates-0.1.8 lib/socrates/string_helpers.rb
socrates-0.1.7 lib/socrates/string_helpers.rb
socrates-0.1.6 lib/socrates/string_helpers.rb
socrates-0.1.4 lib/socrates/string_helpers.rb
socrates-0.1.3 lib/socrates/string_helpers.rb