Class: Datafile::Dataset

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

Direct Known Subclasses

BeerDataset, FootballDataset, WorldDataset

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, opts = {}) ⇒ Dataset

Returns a new instance of Dataset.



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

def initialize( name, opts={} )
  @name = name
  @opts = opts
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



30
31
32
# File 'lib/datafile/dataset.rb', line 30

def name
  @name
end

#optsObject (readonly)

Returns the value of attribute opts.



30
31
32
# File 'lib/datafile/dataset.rb', line 30

def opts
  @opts
end

Instance Method Details

#file?Boolean

note: use file? (not exit? might use zip? later to check if zip exists? -why? why not?)

Returns:

  • (Boolean)


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/datafile/dataset.rb', line 37

def file?                    # note: use file? (not exit? might use zip? later to check if zip exists? -why? why not?)
  ## hack/convenience shortcut:
  ##   1) check if dataset exists as local (in situ) file dataset
  ##    e.g. working folder  == name of dataset
  ##
  ##   todo/fix: 2) also check
  ##                   via (file)registry - why, why not??

  ## split name in org/user + project (e.g. openfootball/at-austria)
  parts = @name.split( '/' )

  basename = parts[1]
  ##  e.g.
  ##  ./ (working folder) => at-austria
  ##  openfootball/at-austria
  if File.basename( Dir.getwd ) == basename
    puts "  bingo!! working folder >#{basename}< matches dataset"
    true     ## return true
  else
    false    ## return false
  end
end

#formatObject

note: assume default is txt (other formats incl. csv) for now - why? wh not?



34
# File 'lib/datafile/dataset.rb', line 34

def format()  @opts[:format] || 'txt'; end

#setupObject

convenience helpers for known opts



33
# File 'lib/datafile/dataset.rb', line 33

def setup()   @opts[:setup];           end