Module: VORuby::STC::V1_30::STCReference

Includes:
SerializableToXml
Included in:
Double1Type, ISOTimeType, JDTimeType, PosAngleType, STCBaseType, TimeOffsetType
Defined in:
lib/voruby/stc/1.30/stc.rb

Overview

These four attributes represent the standard IVOA referencing system: internal (within the document) referencing through “id” and “idref”, external referencing through Xlink, using only “type=simple” and “href”.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Instance Attribute Details

#idObject

Returns the value of attribute id.



99
100
101
# File 'lib/voruby/stc/1.30/stc.rb', line 99

def id
  @id
end

#idrefObject

Returns the value of attribute idref.



99
100
101
# File 'lib/voruby/stc/1.30/stc.rb', line 99

def idref
  @idref
end

#ucdObject

Returns the value of attribute ucd.



99
100
101
# File 'lib/voruby/stc/1.30/stc.rb', line 99

def ucd
  @ucd
end

Returns the value of attribute xlink_href.



99
100
101
# File 'lib/voruby/stc/1.30/stc.rb', line 99

def xlink_href
  @xlink_href
end

Returns the value of attribute xlink_type.



99
100
101
# File 'lib/voruby/stc/1.30/stc.rb', line 99

def xlink_type
  @xlink_type
end

Class Method Details

.stc_reference_from_xml(el) ⇒ Object



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/voruby/stc/1.30/stc.rb', line 163

def self.stc_reference_from_xml(el)
  stc_ns = obj_ns('VORuby::STC::V1_30')
  xlink_ns = obj_ns('VORuby::XLink::V1_2')
  
  id_el = el.attributes.get_attribute_ns(stc_ns.uri, 'id')
  idref_el = el.attributes.get_attribute_ns(stc_ns.uri, 'idref')
  ucd_el = el.attributes.get_attribute_ns(stc_ns.uri, 'ucd')
  xlink_type_el = el.attributes.get_attribute_ns(xlink_ns.uri, 'type')
  xlink_href_el = el.attributes.get_attribute_ns(xlink_ns.uri, 'href')
  
  options = {}
  options[:id] = Id.new(id_el.value) if id_el
  options[:idref] = IdRef.new(idref_el.value) if idref_el
  options[:ucd] = ucd_el.value if ucd_el
  options[:xlink_type] = XLink::V1_2::Type.new(xlink_type_el.value) if xlink_type_el
  options[:xlink_href] = URI.parse(xlink_href_el.value) if xlink_href_el
  
  options
end

Instance Method Details

#stc_reference_eq(obj) ⇒ Object



142
143
144
145
146
147
148
# File 'lib/voruby/stc/1.30/stc.rb', line 142

def stc_reference_eq(obj)
  self.id == obj.id and
  self.idref == obj.idref and
  self.ucd == obj.ucd and
  self.xlink_type == obj.xlink_type and
  self.xlink_href == obj.xlink_href
end

#stc_reference_to_xml(el) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/voruby/stc/1.30/stc.rb', line 150

def stc_reference_to_xml(el)
  xlink_ns = obj_ns('VORuby::XLink::V1_2')
  el.add_namespace(xlink_ns.prefix, xlink_ns.uri)
  
  el.attributes["#{obj_ns.prefix}:id"] = self.id.to_s if self.id
  el.attributes["#{obj_ns.prefix}:idref"] = self.idref.to_s if self.idref
  el.attributes["#{obj_ns.prefix}:ucd"] = self.ucd if self.ucd
  el.attributes["#{obj_ns('VORuby::XLink::V1_2').prefix}:type"] = self.xlink_type.to_s if self.xlink_type
  el.attributes["#{obj_ns('VORuby::XLink::V1_2').prefix}:href"] = self.xlink_href.to_s if self.xlink_href
  
  el
end