Class: PopCap::Formatters::Date
- Defined in:
- lib/pop_cap/formatters/date.rb
Overview
Public: This is a formatter for the date tag. It is used to match and return the year.
date - The date can be sent as a string or integer. options - An optional hash for a start & end date range.
The start_date defaults to 1800, end_date defaults
to 2100.
Instance Attribute Summary
Attributes inherited from Formatter
Instance Method Summary collapse
- #end_date ⇒ Object
-
#format ⇒ Object
Public: This method returns a year if it is matched.
- #start_date ⇒ Object
Methods inherited from Formatter
format, #initialize, subclasses, subclasses_demodulized
Constructor Details
This class inherits a constructor from PopCap::Formatters::Formatter
Instance Method Details
#end_date ⇒ Object
30 31 32 |
# File 'lib/pop_cap/formatters/date.rb', line 30 def end_date [:end_date] || 2100 end |
#format ⇒ Object
21 22 23 24 |
# File 'lib/pop_cap/formatters/date.rb', line 21 def format return unless ( date_match && within_date_range? ) @match[0].to_i end |
#start_date ⇒ Object
26 27 28 |
# File 'lib/pop_cap/formatters/date.rb', line 26 def start_date [:start_date] || 1800 end |