Class: Datafile::Datafile
- Inherits:
-
Object
- Object
- Datafile::Datafile
- Includes:
- LogUtils::Logging
- Defined in:
- lib/datafile/datafile.rb
Instance Attribute Summary collapse
-
#datasets ⇒ Object
readonly
Returns the value of attribute datasets.
-
#deps ⇒ Object
readonly
dep(endencies).
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#scripts ⇒ Object
readonly
calc(ulation) scripts (calc blocks).
-
#worker ⇒ Object
lets you change worker - find a better way - how, why, why not??.
Class Method Summary collapse
-
.load(code) ⇒ Object
another convenience method - use like Datafile.load().
-
.load_file(path = './Datafile') ⇒ Object
convenience method - use like Datafile.load_file().
Instance Method Summary collapse
- #calc ⇒ Object
- #download ⇒ Object
- #dump ⇒ Object
-
#initialize(opts = {}) ⇒ Datafile
constructor
A new instance of Datafile.
- #read ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Datafile
Returns a new instance of Datafile.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/datafile/datafile.rb', line 44 def initialize( opts={} ) @opts = opts @datasets = [] @scripts = [] ## calculation scripts (calc blocks) ## (target)name - return nil if noname (set/defined/assigned) @name = opts[:name] || nil ## deps (dependencies) - note: always returns an array (empty array if no deps) @deps = opts[:deps] || [] if opts[:file] @worker = FileWorker.new( self ) else ## default to zip worker for now @worker = ZipWorker.new( self ) end end |
Instance Attribute Details
#datasets ⇒ Object (readonly)
Returns the value of attribute datasets.
62 63 64 |
# File 'lib/datafile/datafile.rb', line 62 def datasets @datasets end |
#deps ⇒ Object (readonly)
dep(endencies)
65 66 67 |
# File 'lib/datafile/datafile.rb', line 65 def deps @deps end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
64 65 66 |
# File 'lib/datafile/datafile.rb', line 64 def name @name end |
#scripts ⇒ Object (readonly)
calc(ulation) scripts (calc blocks)
63 64 65 |
# File 'lib/datafile/datafile.rb', line 63 def scripts @scripts end |
#worker ⇒ Object
lets you change worker - find a better way - how, why, why not??
67 68 69 |
# File 'lib/datafile/datafile.rb', line 67 def worker @worker end |
Class Method Details
.load(code) ⇒ Object
another convenience method - use like Datafile.load()
32 33 34 35 36 37 38 39 |
# File 'lib/datafile/datafile.rb', line 32 def self.load( code ) builder = Builder.new builder.instance_eval( code ) # Note: return datafile (of course, NOT the builder) # if you want a builder use Datafile::Builder ;-) builder.datafile end |
.load_file(path = './Datafile') ⇒ Object
convenience method - use like Datafile.load_file()
26 27 28 29 |
# File 'lib/datafile/datafile.rb', line 26 def self.load_file( path='./Datafile' ) code = File.read_utf8( path ) self.load( code ) end |
Instance Method Details
#calc ⇒ Object
90 91 92 93 |
# File 'lib/datafile/datafile.rb', line 90 def calc logger.info( "[datafile] calc" ) @worker.calc end |
#download ⇒ Object
79 80 81 82 83 |
# File 'lib/datafile/datafile.rb', line 79 def download logger.info( "[datafile] dowload" ) @worker.download ## check: use @worker.download( @datasets) - why, why not?? link worker w/ datafile - why, why not?? end |
#dump ⇒ Object
95 96 97 98 99 |
# File 'lib/datafile/datafile.rb', line 95 def dump ## for debugging dump datasets (note: will/might also check if zip exits) logger.info( "[datafile] dump datasets (for debugging)" ) @worker.dump end |
#read ⇒ Object
85 86 87 88 |
# File 'lib/datafile/datafile.rb', line 85 def read logger.info( "[datafile] read" ) @worker.read end |
#run ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/datafile/datafile.rb', line 70 def run logger.info( "[datafile] begin - run" ) download # step 1 - download zips for datasets read # step 2 - read in datasets from zips calc # step 3 - run calc(ulations) scripts logger.info( "[datafile] end - run" ) end |