class Handlebars::Helpers::Inflection::Ordinalize
Ordinalize: Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
Public Instance Methods
handlebars_helper()
click to toggle source
# File lib/handlebars/helpers/inflection/ordinalize.rb, line 51 def handlebars_helper proc do |_context, value| wrapper(parse(value)) end end
parse(value)
click to toggle source
Parse will Ordinalize: Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
@example
puts Ordinalize.new.parse('1') 1st
@example
puts Ordinalize.new.parse('2') 2nd
@example
puts Ordinalize.new.parse('3') 3rd
@example
puts Ordinalize.new.parse('4') 4th
@param [String] value - numeric value @return [String] number value turned to 1st, 2nd, 3rd, 4th etc.
# File lib/handlebars/helpers/inflection/ordinalize.rb, line 43 def parse(value) return '' if value.nil? value = value.to_i if value.is_a? String value.ordinalize end