Module: Laborantin::Metaprog::Exports
Instance Method Summary collapse
- #export(name, mime = 'plain/text') ⇒ Object
- #export_file ⇒ Object
- #export_path ⇒ Object
- #exports ⇒ Object
- #load_exports ⇒ Object
- #plots ⇒ Object
- #save_exports ⇒ Object
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_file ⇒ Object
25 26 27 |
# File 'lib/laborantin/core/exports.rb', line 25 def export_file raise NotImplementedError, "should override" end |
#export_path ⇒ Object
21 22 23 |
# File 'lib/laborantin/core/exports.rb', line 21 def export_path raise NotImplementedError, "should override" end |
#exports ⇒ Object
29 30 31 |
# File 'lib/laborantin/core/exports.rb', line 29 def exports @exports ||= load_exports || {} end |
#load_exports ⇒ Object
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 |
#plots ⇒ Object
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_exports ⇒ Object
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 |