Class: Cmdlet::Inflection::Ordinalize

Inherits:
BaseCmdlet
  • Object
show all
Defined in:
lib/cmdlet/inflection/ordinalize.rb

Overview

Ordinalize: Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.

Instance Method Summary collapse

Methods inherited from BaseCmdlet

#tokenizer

Instance Method Details

#call(value) ⇒ String

Returns number value turned to 1st, 2nd, 3rd, 4th etc.

Parameters:

  • value (Int)
    • value - numeric value

Returns:

  • (String)

    number value turned to 1st, 2nd, 3rd, 4th etc.



11
12
13
14
15
16
17
# File 'lib/cmdlet/inflection/ordinalize.rb', line 11

def call(value)
  return '' if value.nil?

  value = value.to_i if value.is_a? String

  value.ordinalize
end