Class: Chronic::Ordinal
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Tag
Class Method Summary collapse
-
.scan(tokens, options) ⇒ Array
Scan an Array of Tokens and apply any necessary Ordinal tags to each token.
- .scan_for_days(token) ⇒ OrdinalDay?
- .scan_for_ordinals(token) ⇒ Ordinal?
Instance Method Summary collapse
Methods inherited from Tag
Constructor Details
This class inherits a constructor from Chronic::Tag
Class Method Details
.scan(tokens, options) ⇒ Array
Scan an Array of Tokens and apply any necessary Ordinal tags to each token
10 11 12 13 14 15 |
# File 'lib/chronic/ordinal.rb', line 10 def self.scan(tokens, ) tokens.each do |token| if t = scan_for_ordinals(token) then token.tag(t) end if t = scan_for_days(token) then token.tag(t) end end end |
.scan_for_days(token) ⇒ OrdinalDay?
25 26 27 28 29 30 31 |
# File 'lib/chronic/ordinal.rb', line 25 def self.scan_for_days(token) if token.word =~ /^(\d*)(st|nd|rd|th)$/ unless $1.to_i > 31 || $1.to_i < 1 OrdinalDay.new(token.word.to_i) end end end |
Instance Method Details
#to_s ⇒ Object
33 34 35 |
# File 'lib/chronic/ordinal.rb', line 33 def to_s 'ordinal' end |