Class: Kit::DateParser
- Inherits:
-
Object
- Object
- Kit::DateParser
- Defined in:
- lib/kit/date_parser.rb
Overview
Parses dates as they appear in the results table
Instance Method Summary collapse
-
#initialize ⇒ DateParser
constructor
Creates a new
DateParser. -
#parse(element) ⇒ Date?
Returns the first date, if any, in the given
element‘s text.
Constructor Details
#initialize ⇒ DateParser
Creates a new DateParser
7 8 9 |
# File 'lib/kit/date_parser.rb', line 7 def initialize @date_format = '%m/%d/%Y' end |
Instance Method Details
#parse(element) ⇒ Date?
Returns the first date, if any, in the given element‘s text
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kit/date_parser.rb', line 17 def parse(element) part_with_date = element.text.split(' ').find do |date_string| begin string_to_date(date_string) rescue ArgumentError end end if part_with_date string_to_date(part_with_date) end end |