Class: Datafile::FileDataset

Inherits:
Object
  • Object
show all
Includes:
LogUtils::Logging
Defined in:
lib/datafile/workers/file/dataset.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dataset) ⇒ FileDataset

Returns a new instance of FileDataset.



16
17
18
# File 'lib/datafile/workers/file/dataset.rb', line 16

def initialize( dataset )
  @dataset = dataset
end

Class Method Details

.registryObject



11
12
13
14
# File 'lib/datafile/workers/file/dataset.rb', line 11

def self.registry
  @@registry ||= FileDatasetRegistry.new
  @@registry
end

Instance Method Details

#dumpObject



24
25
26
27
28
# File 'lib/datafile/workers/file/dataset.rb', line 24

def dump
  ## for debuggin dump dataset  -- todo (also check if folder exits ??)
  puts "dataset '#{@dataset.name}' opts=#{@dataset.opts.inspect}"     ## use opts.inspect instead of to_json - why? why not?
  puts "  repo-dir '#{repo_dir}'"
end

#readObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/datafile/workers/file/dataset.rb', line 30

def read
  if @dataset.is_a?( FootballDataset )
    logger.info( "read football dataset (file) '#{@dataset.name}', '#{@dataset.setup}'" )

    pack = SportDb::DirPackage.new( repo_dir )
    pack.read( season: @dataset.setup )   ##  note: pass on (optional) setup arg as season (filter) arg for now
  else
    logger.info( "TODO/FIX: read dataset (file) '#{@dataset.name}', '#{@dataset.setup}'; sorry" )
  end
end

#repo_dirObject

check: use (rename to) include dir (or local_repo_dir) - why, why not ???



20
21
22
# File 'lib/datafile/workers/file/dataset.rb', line 20

def repo_dir     ### check: use (rename to) include dir (or local_repo_dir) - why, why not ???
  self.class.registry.lookup( @dataset.name )
end