Sha256: 3be74fb7f22cef6079d98492204c28b77783b00ace6799089705bc41229287a6

Contents?: true

Size: 597 Bytes

Versions: 4

Compression:

Stored size: 597 Bytes

Contents

class String
  ##
  # Pluralises +self+ according to the +amount+.
  #
  # @param  [Integer] amount The number of things.
  # @return [String]         The pluralised word.
  #
  # @example With zero
  #   0.numericise('heffalump') # => "no heffalumps"
  #
  # @example With one
  #   1.numericise('heffalump') # => "one heffalump"
  #
  # @example With two
  #   2.numericise('heffalump') # => "2 heffalumps"
  #
  def numericise(amount)
    case amount
      when 0, nil then "no #{plural}"
      when 1      then "one #{self}"
      else             "#{amount.to_s} #{plural}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
antw-kin-0.3.2 lib/kin/core_ext/string.rb
antw-kin-0.3.3 lib/kin/core_ext/string.rb
antw-kin-0.4.0 lib/kin/core_ext/string.rb
antw-kin-0.4.1 lib/kin/core_ext/string.rb