Class: VORuby::STC::V1_10::Coords::Position2D
- Inherits:
-
Vector2Coordinate
- Object
- CoordinateType
- Vector2Coordinate
- VORuby::STC::V1_10::Coords::Position2D
- Includes:
- Position
- Defined in:
- lib/voruby/stc/1.10/coords.rb
Overview
2-D Position coordinate
Instance Attribute Summary collapse
-
#unit ⇒ Object
Returns the value of attribute unit.
Attributes inherited from Vector2Coordinate
#error, #pix_size, #resolution, #size, #value
Attributes inherited from CoordinateType
Class Method Summary collapse
Instance Method Summary collapse
- #==(p) ⇒ Object
-
#initialize(options = {}) ⇒ Position2D
constructor
A new instance of Position2D.
- #to_xml ⇒ Object
Methods included from SerializableToXml
Constructor Details
#initialize(options = {}) ⇒ Position2D
Returns a new instance of Position2D.
1434 1435 1436 1437 |
# File 'lib/voruby/stc/1.10/coords.rb', line 1434 def initialize(={}) raise_argument_required_error('unit') if !.has_key?(:unit) super() end |
Instance Attribute Details
#unit ⇒ Object
Returns the value of attribute unit.
1432 1433 1434 |
# File 'lib/voruby/stc/1.10/coords.rb', line 1432 def unit @unit end |
Class Method Details
.from_xml(xml) ⇒ Object
1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 |
# File 'lib/voruby/stc/1.10/coords.rb', line 1464 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, CValue2, true) [:error] = xml_to_obj(root, CError2) [:resolution] = xml_to_obj(root, CResolution2) [:size] = xml_to_obj(root, CSize2) [:pix_size] = xml_to_obj(root, CPixSize2) Position2D.new() end |
Instance Method Details
#==(p) ⇒ Object
1481 1482 1483 1484 |
# File 'lib/voruby/stc/1.10/coords.rb', line 1481 def ==(p) super(p) and self.unit == p.unit end |
#to_xml ⇒ Object
1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 |
# File 'lib/voruby/stc/1.10/coords.rb', line 1445 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 |