Class: Baclava::Writer
- Inherits:
-
Object
- Object
- Baclava::Writer
- Defined in:
- lib/baclava/writer.rb
Class Method Summary collapse
- .write(data_map) ⇒ Object
-
.write_data(xml, data, index = nil) ⇒ Object
def self.write_metadata(xml, metadata) xml.s :metadata, ‘xmlns:s’ => ‘org.embl.ebi.escience/xscufl/0.1alpha’ do xml.s :mimeTypes do for mimetype in metadata do xml.s :mimetype, mimetype end end end end.
- .write_doc(data_map) ⇒ Object
- .write_item_list(xml, list) ⇒ Object
- .write_list(xml, list, index) ⇒ Object
Class Method Details
.write(data_map) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/baclava/writer.rb', line 13 def self.write(data_map) xml = Builder::XmlMarkup.new :indent => 2 xml.instruct! xml.b :dataThingMap, 'xmlns:b' => 'http://org.embl.ebi.escience/baclava/0.1alpha' do for key in data_map.keys do data = data_map[key] xml.b :dataThing, 'key' => key do xml.b :myGridDataDocument, 'lsid' => '', 'syntactictype' => '' do #write_metadata xml, data.annotation write_data xml, data.value end end end end end |
.write_data(xml, data, index = nil) ⇒ Object
def self.write_metadata(xml, metadata)
xml.s :metadata, 'xmlns:s' => 'http://org.embl.ebi.escience/xscufl/0.1alpha' do
xml.s :mimeTypes do
for mimetype in do
xml.s :mimetype, mimetype
end
end
end
end
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/baclava/writer.rb', line 39 def self.write_data(xml, data, index = nil) if data.is_a? Array write_list xml, data, index else if index xml.b :dataElement, 'lsid' => '', 'index' => index do xml.b :dataElementData, Base64.encode64(data) end else xml.b :dataElement, 'lsid' => '' do xml.b :dataElementData, Base64.encode64(data) end end end end |
.write_doc(data_map) ⇒ Object
9 10 11 |
# File 'lib/baclava/writer.rb', line 9 def self.write_doc(data_map) REXML::Document.new(write(data_map)) end |
.write_item_list(xml, list) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/baclava/writer.rb', line 68 def self.write_item_list(xml, list) xml.b :relationList for i in 0..list.length - 1 do xml.b :relation, 'parent' => i, 'child' => i + 1 end xml.b :itemList do for i in 0..list.length - 1 do write_data xml, list[i], i end end end |
.write_list(xml, list, index) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/baclava/writer.rb', line 56 def self.write_list(xml, list, index) if index xml.b :partialOrder, 'lsid' => '', 'type' => 'list', 'index' => index do write_item_list xml, list end else xml.b :partialOrder, 'lsid' => '', 'type' => 'list' do write_item_list xml, list end end end |