Class: CodelessCode::Filters::Date::Matcher
- Inherits:
-
Object
- Object
- CodelessCode::Filters::Date::Matcher
- Defined in:
- lib/codeless_code/filters/date.rb
Class Method Summary collapse
-
.parse(str) ⇒ Object
param str [String] A date like
2010,2010-12, or2010-12-23.
Instance Method Summary collapse
- #<=(other) ⇒ Object
- #==(other) ⇒ Object
- #>=(other) ⇒ Object
-
#initialize(date, match:) ⇒ Matcher
constructor
A new instance of Matcher.
Constructor Details
#initialize(date, match:) ⇒ Matcher
Returns a new instance of Matcher.
59 60 61 62 |
# File 'lib/codeless_code/filters/date.rb', line 59 def initialize(date, match:) @date = date @match = match end |
Class Method Details
.parse(str) ⇒ Object
param str [String] A date like 2010, 2010-12, or 2010-12-23
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/codeless_code/filters/date.rb', line 45 def self.parse(str) match = :day if str.size == 4 str = "#{str}-01-01" match = :year elsif str.size == 7 str = "#{str}-01" match = :month end new(::Date.parse(str), match: match) end |
Instance Method Details
#<=(other) ⇒ Object
72 73 74 |
# File 'lib/codeless_code/filters/date.rb', line 72 def <=(other) cmp(@date, other, :<=, @match) end |
#==(other) ⇒ Object
64 65 66 |
# File 'lib/codeless_code/filters/date.rb', line 64 def ==(other) cmp(@date, other, :==, @match) end |
#>=(other) ⇒ Object
68 69 70 |
# File 'lib/codeless_code/filters/date.rb', line 68 def >=(other) cmp(@date, other, :>=, @match) end |