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.
258 259 260 |
# File 'lib/voruby/votable/votable.rb', line 258 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.
279 280 281 282 283 284 285 286 287 |
# File 'lib/voruby/votable/votable.rb', line 279 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.
270 271 272 273 |
# File 'lib/voruby/votable/votable.rb', line 270 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']"
264 265 266 |
# File 'lib/voruby/votable/votable.rb', line 264 def xpath_for(klass) "*[local-name()='#{klass.element_name}']" end |