Class: Stockade::Lexemes::Date
- Defined in:
- lib/stockade/lexemes/date.rb
Overview
Date lexeme
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
#==, #end_pos, #initialize, #mask, #range, #token, #type, types, #value
Constructor Details
This class inherits a constructor from Stockade::Lexemes::Base
Class Method Details
.delim ⇒ Object
20 21 22 |
# File 'lib/stockade/lexemes/date.rb', line 20 def delim %r{[\s\.\-\/]} end |
.regex ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/stockade/lexemes/date.rb', line 8 def regex / (?<!\d) (\d{1,4}) #{delim} (\d{1,4}) #{delim} (\d{1,4}) (?!\d) /x end |
Instance Method Details
#valid? ⇒ Boolean
25 26 27 28 29 30 |
# File 'lib/stockade/lexemes/date.rb', line 25 def valid? possible_dates.any? && possible_dates.all? do |date| date <= ::Date.today end end |