Class: Handlebars::Helpers::Inflection::Ordinalize
- Inherits:
-
BaseHelper
- Object
- BaseHelper
- Handlebars::Helpers::Inflection::Ordinalize
- Defined in:
- lib/handlebars/helpers/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
- #handlebars_helper ⇒ Object
-
#parse(value) ⇒ String
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.
Methods inherited from BaseHelper
#parse_json, #struct_to_hash, #tokenizer, #wrapper
Instance Method Details
#handlebars_helper ⇒ Object
51 52 53 54 55 |
# File 'lib/handlebars/helpers/inflection/ordinalize.rb', line 51 def proc do |_context, value| wrapper(parse(value)) end end |
#parse(value) ⇒ String
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.
43 44 45 46 47 48 49 |
# 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 |