Module: SportDb

Defined in:
lib/sportdb/readers.rb,
lib/sportdb/readers/package.rb,
lib/sportdb/readers/version.rb,
lib/sportdb/readers/conf_reader.rb,
lib/sportdb/readers/match_reader.rb

Overview

add convenience shortcut helpers

Defined Under Namespace

Modules: Readers Classes: ConfReader, MatchReader, Package

Class Method Summary collapse

Class Method Details

.parse_club_props(txt) ⇒ Object



27
# File 'lib/sportdb/readers.rb', line 27

def self.parse_club_props( txt )  Import::ClubPropsReader.parse( txt ); end

.parse_clubs(txt) ⇒ Object



30
# File 'lib/sportdb/readers.rb', line 30

def self.parse_clubs( txt )   recs = Import::ClubReader.parse( txt );   Import.catalog.clubs.add( recs ); end

.parse_conf(txt, season: nil) ⇒ Object



20
# File 'lib/sportdb/readers.rb', line 20

def self.parse_conf( txt, season: nil )  ConfReader.parse( txt, season: season ); end

.parse_leagues(txt) ⇒ Object



29
# File 'lib/sportdb/readers.rb', line 29

def self.parse_leagues( txt ) recs = Import::LeagueReader.parse( txt ); Import.catalog.leagues.add( recs ); end

.parse_match(txt, season: nil) ⇒ Object



24
# File 'lib/sportdb/readers.rb', line 24

def self.parse_match( txt, season: nil )  MatchReader.parse( txt, season: season ); end

.read(path, season: nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/sportdb/readers.rb', line 33

def self.read( path, season: nil )
  pack = if File.directory?( path )          ## if directory assume "unzipped" package
            DirPackage.new( path )
         elsif File.file?( path ) && File.extname( path ) == '.zip'   ## check if file is a .zip (archive) file
            ZipPackage.new( path )
         else                                ## no package; assume single (standalone) datafile
           nil
         end

  if pack
     pack.read( season: season )
  else
    if Package.conf?( path )      ## check if datafile matches conf(iguration) naming (e.g. .conf.txt)
      read_conf( path, season: season )
    elsif Package.club_props?( path )
      read_club_props( path )
    else                                ## assume "regular" match datafile
      read_match( path, season: season )
    end
  end
end

.read_club_props(path) ⇒ Object



26
# File 'lib/sportdb/readers.rb', line 26

def self.read_club_props( path )  Import::ClubPropsReader.read( path ); end

.read_conf(path, season: nil) ⇒ Object



19
# File 'lib/sportdb/readers.rb', line 19

def self.read_conf( path, season: nil )  ConfReader.read( path, season: season ); end

.read_match(path, season: nil) ⇒ Object

todo/check: add alias read_matches - why? why not?



23
# File 'lib/sportdb/readers.rb', line 23

def self.read_match( path, season: nil )  MatchReader.read( path, season: season ); end