Class: SportDb::StatusParser

Inherits:
Object
  • Object
show all
Defined in:
lib/sportdb/csv/match_status_parser.rb

Overview

todo/fix - move self.parse to class Status e.g.

use Status.parse( str ) NOT StatusParser...

Class Method Summary collapse

Class Method Details

.parse(str) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/sportdb/csv/match_status_parser.rb', line 33

def self.parse( str )
  ## note: returns nil if no match found
  ## note: english usage - cancelled (in UK), canceled (in US)
  if str =~ /^(cancelled|
               canceled|
               can\.
              )/xi
    Status::CANCELLED
  elsif str =~ /^(awarded|
                   awd\.
                  )/xi
    Status::AWARDED
  elsif str =~ /^(postponed
                  )/xi
    Status::POSTPONED
  elsif str =~ /^(abandoned|
                   abd\.
                  )/xi
    Status::ABANDONED
  elsif str =~ /^(replay
                  )/xi
    Status::REPLAY
  else
    # no match
    nil
  end
end