Class: VORuby::STC::V1_10::Coords::Spectral

Inherits:
ScalarCoordinateType show all
Includes:
SerializableToXml
Defined in:
lib/voruby/stc/1.10/coords.rb

Instance Attribute Summary collapse

Attributes inherited from ScalarCoordinateType

#error, #pix_size, #resolution, #size, #value

Attributes inherited from CoordinateType

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Methods inherited from ScalarCoordinateType

#initialize

Methods inherited from CoordinateType

#initialize

Constructor Details

This class inherits a constructor from VORuby::STC::V1_10::Coords::ScalarCoordinateType

Instance Attribute Details

#unitObject

Returns the value of attribute unit.



2028
2029
2030
# File 'lib/voruby/stc/1.10/coords.rb', line 2028

def unit
  @unit
end

Class Method Details

.from_xml(xml) ⇒ Object



2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
# File 'lib/voruby/stc/1.10/coords.rb', line 2054

def self.from_xml(xml)
  root = element_from(xml)

  options = {
   :name => REXML::XPath.first(root, 'x:Name', {'x' => obj_ns.uri}).text
  }
  unit = root.attributes.get_attribute_ns(obj_ns.uri, 'unit')
  options[:unit] = SpectralUnit.new(unit.value) if unit
  options[:value] = xml_to_obj(root, CValue, true)
  options[:error] = xml_to_obj(root, CError)
  options[:resolution] = xml_to_obj(root, CResolution)
  options[:size] = xml_to_obj(root, CSize)
  options[:pix_size] = xml_to_obj(root, CPixSize)

  Spectral.new(options)
end

Instance Method Details

#==(c) ⇒ Object



2071
2072
2073
# File 'lib/voruby/stc/1.10/coords.rb', line 2071

def ==(c)
  super(c) and self.unit == c.unit
end

#to_xmlObject



2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
# File 'lib/voruby/stc/1.10/coords.rb', line 2035

def to_xml
  el = element()
  el.attributes["#{obj_ns.prefix}:unit"] = self.unit.to_s if self.unit

  name = REXML::Element.new("#{obj_ns.prefix}:Name")
  name.text = self.name

  el.add_element(name)
  el.add_element(self.value.to_xml) if self.value
  self.error.each { |e| el.add_element(e.to_xml) } if self.error
  self.resolution.each { |r| el.add_element(r.to_xml) } if self.resolution
  self.size.each { |s| el.add_element(s.to_xml) } if self.size
  self.pix_size.each { |p| el.add_element(p.to_xml) } if self.pix_size
  
  collapse_namespaces(el)

  el
end