Module: Laborantin::Metaprog::Exports

Included in:
Analysis, Scenario
Defined in:
lib/laborantin/core/exports.rb

Instance Method Summary collapse

Instance Method Details

#export(name, mime = 'plain/text') ⇒ Object



33
34
35
36
# File 'lib/laborantin/core/exports.rb', line 33

def export(name, mime='plain/text')
  log "#{mime}: #{name}" if respond_to? :log
  exports[name] ||= mime
end

#export_fileObject

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/laborantin/core/exports.rb', line 25

def export_file
  raise NotImplementedError, "should override"
end

#export_pathObject

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/laborantin/core/exports.rb', line 21

def export_path
  raise NotImplementedError, "should override"
end

#exportsObject



29
30
31
# File 'lib/laborantin/core/exports.rb', line 29

def exports
  @exports ||= load_exports || {}
end

#load_exportsObject



14
15
16
17
18
19
# File 'lib/laborantin/core/exports.rb', line 14

def load_exports
  path = export_path
  if File.file?(path)
    YAML.load_file(path)
  end
end

#plotsObject



38
39
40
41
# File 'lib/laborantin/core/exports.rb', line 38

def plots
  hash = exports
  hash.keys.select{|k| hash[k] =~ /^image/}
end

#save_exportsObject



7
8
9
10
11
12
# File 'lib/laborantin/core/exports.rb', line 7

def save_exports
  log "saving exports: #{exports}" if respond_to? :log
  export_file('w') do |f|
    f.puts YAML.dump(exports)
  end
end