Class: Datafile::Datafile

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDatafile

Returns a new instance of Datafile.



26
27
28
# File 'lib/datafile/datafile.rb', line 26

def initialize()
  @datasets = []
end

Instance Attribute Details

#datasetsObject (readonly)

Returns the value of attribute datasets.



9
10
11
# File 'lib/datafile/datafile.rb', line 9

def datasets
  @datasets
end

Class Method Details

.load(code) ⇒ Object

another convenience method - use like Datafile.load()



19
20
21
22
23
# File 'lib/datafile/datafile.rb', line 19

def self.load( code )
  builder = Builder.new
  builder.instance_eval( code )
  builder.datafile   # note: return datafile (of course, NOT the builder)
end

.load_file(path = './Datafile') ⇒ Object

convenience method - use like Datafile.load_file()



13
14
15
16
# File 'lib/datafile/datafile.rb', line 13

def self.load_file( path='./Datafile' )
  code = File.read_utf8( path )
  self.load( code )
end

Instance Method Details

#downloadObject



38
39
40
41
42
43
# File 'lib/datafile/datafile.rb', line 38

def download()
  logger.info( "[datafile] dowload" )
  @datasets.each do |dataset|
    dataset.download()
  end
end

#readObject



45
46
47
48
49
50
# File 'lib/datafile/datafile.rb', line 45

def read()
  logger.info( "[datafile] read" )
  @datasets.each do |dataset|
    dataset.read()
  end
end

#runObject



31
32
33
34
35
36
# File 'lib/datafile/datafile.rb', line 31

def run()
  logger.info( "[datafile] begin - run" )
  download()   # step 1 - download zips for datasets
  read()       # step 2 - read in datasets from zips
  logger.info( "[datafile] end - run" )
end