Class: SportDb::Package

Inherits:
Object
  • Object
show all
Defined in:
lib/sportdb/readers/package.rb

Instance Method Summary collapse

Instance Method Details

#read(*names, season: nil) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/sportdb/readers/package.rb', line 47

def read( *names, season: nil )
  if names.empty?   ##  read all datafiles
    read_leagues()
    read_clubs()
    read_club_props()
    ## note:  skip conf(iguration)s for now!!!!!!!
    ## read_conf( season: season )
    read_match( season: season )
  else
    names.each do |name|
      entry = @pack.find( name )
      ## fix/todo: add read_leagues, read_clubs too!!!
      if match_conf?( name )      ## check if datafile matches conf(iguration) naming (e.g. .conf.txt)
        SportDb.parse_conf( entry.read, season: season )
      elsif match_club_props?( name )
        SportDb.parse_club_props( entry.read )
      else   ## assume "regular" match datafile or check pattern and report error on fail - why? why not?
        SportDb.parse_match( entry.read, season: season )
      end
    end
  end
end

#read_club_propsObject



15
16
17
# File 'lib/sportdb/readers/package.rb', line 15

def read_club_props
  each_club_props { |entry| SportDb.parse_club_props( entry.read ) }
end

#read_clubsObject



11
12
13
# File 'lib/sportdb/readers/package.rb', line 11

def read_clubs
  each_clubs { |entry| SportDb.parse_clubs( entry.read ) }
end

#read_conf(*names, season: nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sportdb/readers/package.rb', line 20

def read_conf( *names, season: nil )
  if names.empty?   ## no (entry) names passed in; read in all
    each_conf do |entry|
      SportDb.parse_conf( entry.read, season: season )
    end
  else
    names.each do |name|
      entry = @pack.find( name )
      SportDb.parse_conf( entry.read, season: season )
    end
  end
end

#read_leaguesObject

note: add readers here; for full class def see the sourcein sportdb-formats!!!



7
8
9
# File 'lib/sportdb/readers/package.rb', line 7

def read_leagues
  each_leagues { |entry| SportDb.parse_leagues( entry.read ) }
end

#read_match(*names, season: nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/sportdb/readers/package.rb', line 33

def read_match( *names, season: nil )
  if names.empty?   ## no (entry) names passed in; read in all
    each_match do |entry|
      SportDb.parse_match( entry.read, season: season )
    end
  else
    names.each do |name|
      entry = @pack.find( name )
      SportDb.parse_match( entry.read, season: season )
    end
  end
end