Class: VORuby::VOTables::VOTable::LibxmlParsedVOTable
- Defined in:
- lib/voruby/votables/libxml_votable.rb
Overview
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#votable ⇒ Object
readonly
Returns the value of attribute votable.
Instance Method Summary collapse
-
#initialize(path) ⇒ LibxmlParsedVOTable
constructor
- path:
-
The path to the VOTable XML file to parse.
-
#to_s ⇒ Object
Convert a LibxmlParsedVOTable into a string representation.
Constructor Details
#initialize(path) ⇒ LibxmlParsedVOTable
- path:
-
The path to the VOTable XML file to parse.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/voruby/votables/libxml_votable.rb', line 19 def initialize(path) @path = path ; doc = XML::Document.file(path) root = doc.root # Root document # Attributes id = root['ID'] if root['ID'] version = root['version'] if root['version'] # Elements description = Meta::Description.from_xml(root.find('DESCRIPTION').to_a.first) if root.find('DESCRIPTION').length > 0 definition = Meta::Definitions.from_xml(root.find('DEFINITIONS').to_a.first) if root.find('DEFINITIONS').length > 0 coosys = [] root.find('COOSYS').each { |sys| coosys.push(Meta::CooSys.from_xml(sys)) } params = [] root.find('PARAM').each { |param| params.push(Meta::Param.from_xml(param)) } info = [] root.find('INFO').each { |inf| info.push(Meta::Info.from_xml(inf)) } resources = [] root.find('RESOURCE').each { |res| resources.push(Meta::Resource.from_xml(res)) } @votable = VOTable.new(id, version, description, definition, coosys, params, info, resources) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
15 16 17 |
# File 'lib/voruby/votables/libxml_votable.rb', line 15 def path @path end |
#votable ⇒ Object (readonly)
Returns the value of attribute votable.
15 16 17 |
# File 'lib/voruby/votables/libxml_votable.rb', line 15 def votable @votable end |
Instance Method Details
#to_s ⇒ Object
Convert a LibxmlParsedVOTable into a string representation.
59 60 61 |
# File 'lib/voruby/votables/libxml_votable.rb', line 59 def to_s "{file=#{@path};votable=#{@votable}}" end |