Class: VORuby::STC::V1_10::Coords::Position1D
- Inherits:
-
ScalarCoordinateType
- Object
- CoordinateType
- ScalarCoordinateType
- VORuby::STC::V1_10::Coords::Position1D
- Includes:
- Position
- Defined in:
- lib/voruby/stc/1.10/coords.rb
Overview
1-D Position coordinate
Instance Attribute Summary collapse
-
#unit ⇒ Object
Returns the value of attribute unit.
Attributes inherited from ScalarCoordinateType
#error, #pix_size, #resolution, #size, #value
Attributes inherited from CoordinateType
Class Method Summary collapse
Instance Method Summary collapse
- #==(p) ⇒ Object
-
#initialize(options = {}) ⇒ Position1D
constructor
A new instance of Position1D.
- #to_xml ⇒ Object
Methods included from SerializableToXml
Constructor Details
#initialize(options = {}) ⇒ Position1D
Returns a new instance of Position1D.
1375 1376 1377 1378 |
# File 'lib/voruby/stc/1.10/coords.rb', line 1375 def initialize(={}) raise_argument_required_error('unit') if !.has_key?(:unit) super() end |
Instance Attribute Details
#unit ⇒ Object
Returns the value of attribute unit.
1373 1374 1375 |
# File 'lib/voruby/stc/1.10/coords.rb', line 1373 def unit @unit end |
Class Method Details
.from_xml(xml) ⇒ Object
1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 |
# File 'lib/voruby/stc/1.10/coords.rb', line 1405 def self.from_xml(xml) root = element_from(xml) = { :name => REXML::XPath.first(root, 'x:Name', {'x' => obj_ns.uri}).text } unit = root.attributes.get_attribute_ns(obj_ns.uri, 'unit') [:unit] = PosUnit.new(unit.value) if unit [:value] = xml_to_obj(root, CValue, true) [:error] = xml_to_obj(root, CError) [:resolution] = xml_to_obj(root, CResolution) [:size] = xml_to_obj(root, CSize) [:pix_size] = xml_to_obj(root, CPixSize) Position1D.new() end |
Instance Method Details
#==(p) ⇒ Object
1422 1423 1424 1425 |
# File 'lib/voruby/stc/1.10/coords.rb', line 1422 def ==(p) super(p) and self.unit == p.unit end |
#to_xml ⇒ Object
1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 |
# File 'lib/voruby/stc/1.10/coords.rb', line 1386 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 |