Class: Cmdlet::Inflection::Ordinal

Inherits:
BaseCmdlet show all
Defined in:
lib/cmdlet/inflection/ordinal.rb

Overview

Ordinal: The suffix that should be added to a number 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 ordinal suffix that would be required for a number.

Parameters:

  • value (String|Int)
    • value - numeric value

Returns:

  • (String)

    ordinal suffix that would be required for a number



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

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

  value = value.to_i if value.is_a? String

  value.ordinal
end