Class: SportDb::RsssfDateFinder
- Inherits:
-
DateFinderBase
- Object
- DateFinderBase
- SportDb::RsssfDateFinder
- Includes:
- LogUtils::Logging
- Defined in:
- lib/sportdb/finders/date.rb
Constant Summary collapse
- MONTH_EN =
'Jan|'+ 'Feb|'+ 'March|Mar|'+ 'April|Apr|'+ 'May|'+ 'June|Jun|'+ 'July|Jul|'+ 'Aug|'+ 'Sept|Sep|'+ 'Oct|'+ 'Nov|'+ 'Dec'
- EN__MONTH_DD__DATE_REGEX =
e.g.
[Jun 7] or [Aug 12] etc. - not MUST include brackets e.g. [] check add \b at the beginning and end - why?? why not?? working??
/\[ (?<month_en>#{MONTH_EN}) \s (?<day>\d{1,2}) \]/x
Constants inherited from DateFinderBase
DateFinderBase::MONTH_EN_TO_MM, DateFinderBase::MONTH_ES_TO_MM, DateFinderBase::MONTH_FR_TO_MM
Instance Method Summary collapse
Instance Method Details
#find!(line, opts = {}) ⇒ Object
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
# File 'lib/sportdb/finders/date.rb', line 425 def find!( line, opts={} ) # fix: use more lookahead for all required trailing spaces!!!!! # fix: use <name capturing group> for month,day,year etc.!!! tag = '[EN_MONTH_DD]' pattern = EN__MONTH_DD__DATE_REGEX md = pattern.match( line ) if md date = parse_date_time( md, opts ) ## fix: use md[0] e.g. match for sub! instead of using regex again - why? why not??? ## fix: use md.begin(0), md.end(0) line.sub!( md[0], tag ) ## todo/fix: make sure match data will not get changed (e.g. using sub! before parse_date_time) return date end return nil # no match found end |