Class: Viiite::BDB::Immediate

Inherits:
Object
  • Object
show all
Includes:
Alf::Iterator, Utils
Defined in:
lib/viiite/bdb/immediate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#bench_file, #replace_extension

Constructor Details

#initialize(folder, pattern = DEFAULT_OPTIONS[:pattern]) ⇒ Immediate

Returns a new instance of Immediate.



9
10
11
12
13
14
15
16
17
18
# File 'lib/viiite/bdb/immediate.rb', line 9

def initialize(folder, pattern = DEFAULT_OPTIONS[:pattern])
  @folder = folder
  if pattern =~ /(\.\w+)$/
    @pattern = pattern
    @ext = $1
  else
    raise InvalidPattern, "The benchmark suite pattern must end with a unique extension " <<
                          "(for deducing benchmark file from name): #{pattern}"
  end
end

Instance Attribute Details

#folderObject (readonly)

Returns the value of attribute folder.



7
8
9
# File 'lib/viiite/bdb/immediate.rb', line 7

def folder
  @folder
end

Instance Method Details

#benchmark(name) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/viiite/bdb/immediate.rb', line 30

def benchmark(name)
  if File.exists?(file = bench_file(folder, name.to_s, @ext))
    return Alf::Reader.reader(file, self)
  else
    raise NoSuchBenchmarkError, "No such benchmark #{name}"
  end
end

#cached?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/viiite/bdb/immediate.rb', line 26

def cached?
  false
end

#dataset(name) ⇒ Object



38
39
40
41
42
# File 'lib/viiite/bdb/immediate.rb', line 38

def dataset(name)
  benchmark(name)
rescue NoSuchBenchmarkError => ex
  raise Alf::NoSuchDatasetError, ex.message, ex.backtrace
end

#eachObject



20
21
22
23
24
# File 'lib/viiite/bdb/immediate.rb', line 20

def each
  Dir[File.join(folder, @pattern)].each do |f|
    yield(:name => f[1+folder.size..-1-@ext.size], :file => f)
  end
end