Class: VORuby::VOTable::Base
- Inherits:
-
XML::Object::Base
- Object
- XML::Object::Base
- VORuby::VOTable::Base
- Defined in:
- lib/voruby/votable/votable.rb
Overview
The base class that all VOTable domain objects derive from. You’ll never instantiate this directly.
Direct Known Subclasses
V1_0::Binary, V1_0::Coosys, V1_0::Data, V1_0::Definitions, V1_0::Description, V1_0::Field, V1_0::Fits, V1_0::Info, V1_0::Link, V1_0::Max, V1_0::Min, V1_0::Option, V1_0::Param, V1_0::Resource, V1_0::Stream, V1_0::Table, V1_0::TableData, V1_0::Td, V1_0::Tr, V1_0::VOTable, V1_0::Values, V1_1::Binary, V1_1::Coosys, V1_1::Data, V1_1::Definitions, V1_1::Description, V1_1::Field, V1_1::FieldRef, V1_1::Fits, V1_1::Group, V1_1::Info, V1_1::Link, V1_1::Max, V1_1::Min, V1_1::Option, V1_1::Param, V1_1::ParamRef, V1_1::Resource, V1_1::Stream, V1_1::Table, V1_1::TableData, V1_1::Td, V1_1::Tr, V1_1::VOTable, V1_1::Values
Instance Attribute Summary
Attributes inherited from XML::Object::Base
Class Method Summary collapse
-
.element_name ⇒ Object
Get the name of the element when serialized to XML that the object in question will take on.
Instance Method Summary collapse
-
#==(obj) ⇒ Object
Equality among domain objects.
-
#get_element(klass) ⇒ Object
Retrieve the domain object that corresponds to the specified class.
-
#xpath_for(klass) ⇒ Object
Determine the xpath corresponding to the specified class.
Methods inherited from XML::Object::Base
Constructor Details
This class inherits a constructor from XML::Object::Base
Class Method Details
.element_name ⇒ Object
Get the name of the element when serialized to XML that the object in question will take on.
165 166 167 |
# File 'lib/voruby/votable/votable.rb', line 165 def self.element_name const_get('ELEMENT_NAME') end |
Instance Method Details
#==(obj) ⇒ Object
Equality among domain objects. Two objects are considered equal if they’re of the same class and their accessor methods themselves return objects which are equal.
186 187 188 189 190 191 192 193 194 |
# File 'lib/voruby/votable/votable.rb', line 186 def ==(obj) return false if self.class != obj.class self.methods_to_test_for_equality.each do |method| return false if self.send(method) != obj.send(method) end true end |
#get_element(klass) ⇒ Object
Retrieve the domain object that corresponds to the specified class.
177 178 179 180 |
# File 'lib/voruby/votable/votable.rb', line 177 def get_element(klass) subnode = self.node.find_first("*[local-name()='#{klass.element_name}']") subnode ? klass.new(subnode) : nil end |
#xpath_for(klass) ⇒ Object
Determine the xpath corresponding to the specified class.
obj.xpath_for(Field) # => "*[local-name()='FIELD']"
171 172 173 |
# File 'lib/voruby/votable/votable.rb', line 171 def xpath_for(klass) "*[local-name()='#{klass.element_name}']" end |