Sha256: fcdebdf6fe16311ba19e545046b05cfccc97a6be377135ef4b29883249967df8

Contents?: true

Size: 601 Bytes

Versions: 29

Compression:

Stored size: 601 Bytes

Contents

# frozen_string_literal: true

module Cmdlet
  # Inflection handling routines, eg. pluralize, singular, ordinalize
  module Inflection
    # Ordinalize: Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
    class Ordinalize < Cmdlet::BaseCmdlet
      #
      # @param [Int] value - value - numeric value
      # @return [String] number value turned to 1st, 2nd, 3rd, 4th etc.
      def call(value)
        return '' if value.nil?

        value = value.to_i if value.is_a? String

        value.ordinalize
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
cmdlet-0.14.0 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.13.2 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.13.1 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.13.0 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.12.5 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.12.4 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.12.3 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.12.2 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.12.1 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.12.0 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.11.0 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.10.1 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.10.0 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.9.2 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.9.1 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.9.0 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.8.0 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.7.1 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.7.0 lib/cmdlet/inflection/ordinalize.rb
cmdlet-0.6.2 lib/cmdlet/inflection/ordinalize.rb