Class: VORuby::VOTable::V1_1::FieldRef

Inherits:
Base show all
Defined in:
lib/voruby/votable/1.1/votable.rb

Overview

A reference to an existing Field.

Constant Summary collapse

ELEMENT_NAME =
'FIELDref'

Instance Attribute Summary

Attributes inherited from XML::Object::Base

#node

Instance Method Summary collapse

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) ⇒ FieldRef

Create a new field reference.

fref = FieldRef.new(:ref => 'col3')


1655
1656
1657
# File 'lib/voruby/votable/1.1/votable.rb', line 1655

def initialize(defn=nil)
  super(defn)
end

Instance Method Details

#fieldObject

Retrieve the field (Field) associated with this reference.



1668
1669
1670
1671
# File 'lib/voruby/votable/1.1/votable.rb', line 1668

def field
  field_node = self.node.find_first("ancestor::*/FIELD[@ID='#{self.ref}']")
  field_node ? Field.new(field_node) : nil
end

#refObject



1659
1660
1661
# File 'lib/voruby/votable/1.1/votable.rb', line 1659

def ref
  self.node['ref']
end

#ref=(r) ⇒ Object



1663
1664
1665
# File 'lib/voruby/votable/1.1/votable.rb', line 1663

def ref=(r)
  @node['ref'] = r.to_s
end