Class: VORuby::VOTable::V1_1::VOTable
- Inherits:
-
Base
- Object
- XML::Object::Base
- Base
- VORuby::VOTable::V1_1::VOTable
- Defined in:
- lib/voruby/votable/1.1/votable.rb
Overview
The root element of the votable.
Constant Summary collapse
- ELEMENT_NAME =
'VOTABLE'
Instance Attribute Summary
Attributes inherited from XML::Object::Base
Class Method Summary collapse
Instance Method Summary collapse
-
#coordinate_systems ⇒ Object
Retrieve the coordinate systems (Coosys).
-
#coordinate_systems=(systems) ⇒ Object
Set the coordinate systems.
-
#definitions ⇒ Object
Retrieve the definitions (Definitions).
-
#definitions=(d) ⇒ Object
Set the definitions (Definitions).
-
#description ⇒ Object
Retrieve the description (Description).
-
#description=(d) ⇒ Object
Set the description (Description).
- #id ⇒ Object
- #id=(i) ⇒ Object
-
#infos ⇒ Object
Retrieve the information list (Info).
-
#infos=(is) ⇒ Object
Set the information list.
-
#initialize(defn = nil) ⇒ VOTable
constructor
Create a votable.
-
#params ⇒ Object
Retrieve the parameters (Param).
-
#params=(parameters) ⇒ Object
Set the parameters.
-
#resources ⇒ Object
Retrieve the resources (Resource).
-
#resources=(res) ⇒ Object
Set the resources.
-
#to_html ⇒ Object
Convert a VOTable to HTML.
-
#version ⇒ Object
Retrieve the version.
-
#version=(v) ⇒ Object
Set the version.
Methods inherited from Base
#==, element_name, #get_element, #xpath_for
Methods inherited from XML::Object::Base
#==, element_name, from_file, #to_s
Constructor Details
#initialize(defn = nil) ⇒ VOTable
Create a votable. To parse an existing votable one would normally do this:
votable = VOTable.from_file('my_file.xml')
but any of the other methods described in VOTable::Base#new are also acceptable:
votable = VOTable.new(
:version => '1.1',
:id => 'votable1',
:description => Description.new(:text => 'A test votable'),
:resources => [Resource.new(...)]
) # etc.
or to create a blank VOTable that you’ll build up later:
votable = VOTable.new()
34 35 36 37 |
# File 'lib/voruby/votable/1.1/votable.rb', line 34 def initialize(defn=nil) super(defn) self.version = '1.1' if !self.version end |
Class Method Details
.serialization_order ⇒ Object
14 15 16 17 18 19 |
# File 'lib/voruby/votable/1.1/votable.rb', line 14 def self.serialization_order [ :description, :definitions, :coordinate_systems, :params, :infos, :resources, :version, :id ] end |
Instance Method Details
#coordinate_systems ⇒ Object
Retrieve the coordinate systems (Coosys).
82 83 84 |
# File 'lib/voruby/votable/1.1/votable.rb', line 82 def coordinate_systems HomogeneousNodeList.new(self.node, xpath_for(Coosys), Coosys) end |
#coordinate_systems=(systems) ⇒ Object
Set the coordinate systems. Takes an array of Coosys objects.
votable.coordinate_systems = [Coosys.new(), ...]
89 90 91 |
# File 'lib/voruby/votable/1.1/votable.rb', line 89 def coordinate_systems=(systems) self.coordinate_systems.replace(systems) end |
#definitions ⇒ Object
Retrieve the definitions (Definitions). Deprecated.
71 72 73 |
# File 'lib/voruby/votable/1.1/votable.rb', line 71 def definitions get_element(Definitions) end |
#definitions=(d) ⇒ Object
Set the definitions (Definitions). Deprecated.
77 78 79 |
# File 'lib/voruby/votable/1.1/votable.rb', line 77 def definitions=(d) set_element(Definitions, d) end |
#description ⇒ Object
Retrieve the description (Description).
59 60 61 |
# File 'lib/voruby/votable/1.1/votable.rb', line 59 def description get_element(Description) end |
#description=(d) ⇒ Object
Set the description (Description).
votable.description = Description.new(:text => 'A fascinating votable')
65 66 67 |
# File 'lib/voruby/votable/1.1/votable.rb', line 65 def description=(d) set_element(Description, d) end |
#id ⇒ Object
50 51 52 |
# File 'lib/voruby/votable/1.1/votable.rb', line 50 def id self.node['ID'] end |
#id=(i) ⇒ Object
54 55 56 |
# File 'lib/voruby/votable/1.1/votable.rb', line 54 def id=(i) @node['ID'] = i.to_s end |
#infos ⇒ Object
Retrieve the information list (Info). Returns a HomogeneousNodeList.
108 109 110 |
# File 'lib/voruby/votable/1.1/votable.rb', line 108 def infos HomogeneousNodeList.new(self.node, xpath_for(Info), Info) end |
#infos=(is) ⇒ Object
Set the information list. Takes an array of Info objects.
votable.infos = [Info.new(), ...]
115 116 117 |
# File 'lib/voruby/votable/1.1/votable.rb', line 115 def infos=(is) self.infos.replace(is) end |
#params ⇒ Object
Retrieve the parameters (Param). Returns a HomogeneousNodeList.
95 96 97 |
# File 'lib/voruby/votable/1.1/votable.rb', line 95 def params HomogeneousNodeList.new(self.node, xpath_for(Param), Param) end |
#params=(parameters) ⇒ Object
Set the parameters. Takes an array of Param objects.
votable.params = [Param.new(), ...]
102 103 104 |
# File 'lib/voruby/votable/1.1/votable.rb', line 102 def params=(parameters) self.params.replace(parameters) end |
#resources ⇒ Object
Retrieve the resources (Resource). Returns a HomogeneousNodeList.
121 122 123 |
# File 'lib/voruby/votable/1.1/votable.rb', line 121 def resources HomogeneousNodeList.new(self.node, xpath_for(Resource), Resource) end |
#resources=(res) ⇒ Object
Set the resources. Takes an array of Resource objects.
votable.resources = [Resource.new(), ...]
128 129 130 |
# File 'lib/voruby/votable/1.1/votable.rb', line 128 def resources=(res) self.resources.replace(res) end |
#to_html ⇒ Object
Convert a VOTable to HTML. Not all attributes are converted. See test/voruby/votable/1.1/votable.html for an example of the output.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/voruby/votable/1.1/votable.rb', line 135 def to_html builder = Builder::XmlMarkup.new(:indent => 2) votable_opts = {:class => 'votable'} votable_opts[:id] = self.id if self.id builder.div(votable_opts){ |votable| votable.div(self.description.text, :class => 'description') if self.description self.resources.each do |res| votable << res.to_html end } end |
#version ⇒ Object
Retrieve the version. By default this is ‘1.1’.
40 41 42 |
# File 'lib/voruby/votable/1.1/votable.rb', line 40 def version self.node['version'] end |
#version=(v) ⇒ Object
Set the version. Normally you should leave this as 1.1.
46 47 48 |
# File 'lib/voruby/votable/1.1/votable.rb', line 46 def version=(v) @node['version'] = v.to_s end |