Class: VORuby::STC::V1_30::Double2Type

Inherits:
STCBaseType show all
Defined in:
lib/voruby/stc/1.30/stc.rb

Overview

A vector of 2 doubles; components are now separated.

Direct Known Subclasses

Size2Type, Value2

Instance Attribute Summary collapse

Attributes included from STCReference

#id, #idref, #ucd, #xlink_href, #xlink_type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from STCBaseType

stc_base_from_xml

Methods included from STCReference

#stc_reference_eq, stc_reference_from_xml, #stc_reference_to_xml

Methods included from SerializableToXml

#element

Constructor Details

#initialize(c1, c2, options = {}) ⇒ Double2Type

Returns a new instance of Double2Type.



671
672
673
674
675
# File 'lib/voruby/stc/1.30/stc.rb', line 671

def initialize(c1, c2, options={})
  self.c1 = c1
  self.c2 = c2
  super(options)
end

Instance Attribute Details

#c1Object

Returns the value of attribute c1.



669
670
671
# File 'lib/voruby/stc/1.30/stc.rb', line 669

def c1
  @c1
end

#c2Object

Returns the value of attribute c2.



669
670
671
# File 'lib/voruby/stc/1.30/stc.rb', line 669

def c2
  @c2
end

#gen_unitObject

Returns the value of attribute gen_unit.



669
670
671
# File 'lib/voruby/stc/1.30/stc.rb', line 669

def gen_unit
  @gen_unit
end

#unitObject

Returns the value of attribute unit.



669
670
671
# File 'lib/voruby/stc/1.30/stc.rb', line 669

def unit
  @unit
end

#vel_time_unitObject

Returns the value of attribute vel_time_unit.



669
670
671
# File 'lib/voruby/stc/1.30/stc.rb', line 669

def vel_time_unit
  @vel_time_unit
end

Class Method Details

.double2_from_xml(root) ⇒ Object



744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
# File 'lib/voruby/stc/1.30/stc.rb', line 744

def self.double2_from_xml(root)
  c1_el = REXML::XPath.first(root, 'x:C1', {'x' => obj_ns.uri})
  c2_el = REXML::XPath.first(root, 'x:C2', {'x' => obj_ns.uri})
  
  options = STCBaseType.stc_base_from_xml(root)
  
  unit = root.attributes.get_attribute_ns(obj_ns.uri, 'unit')
  options[:unit] = PosUnitType.new(unit.value) if unit
  
  vel_time_unit = root.attributes.get_attribute_ns(obj_ns.uri, 'vel_time_unit')
  options[:vel_time_unit] = VelTimeUnitType.new(vel_time_unit.value) if vel_time_unit
  
  gen_unit = root.attributes.get_attribute_ns(obj_ns.uri, 'gen_unit')
  options[:gen_unit] = UnitType.new(gen_unit.value) if gen_unit
  
  [c1_el ? Double1Type.from_xml(c1_el) : nil, c2_el ? Double1Type.from_xml(c2_el) : nil, options]
end

.from_xml(xml) ⇒ Object



762
763
764
765
# File 'lib/voruby/stc/1.30/stc.rb', line 762

def self.from_xml(xml)
  root = element_from(xml)
  self.new(*double2_from_xml(root))
end

Instance Method Details

#==(d) ⇒ Object



717
718
719
720
721
722
723
724
# File 'lib/voruby/stc/1.30/stc.rb', line 717

def ==(d)
  super(d) and
  self.c1 == d.c1 and
  self.c2 == d.c2 and
  self.unit == d.unit and
  self.vel_time_unit == d.vel_time_unit and
  self.gen_unit == d.gen_unit
end

#to_sObject



740
741
742
# File 'lib/voruby/stc/1.30/stc.rb', line 740

def to_s
  "#{self.c1} #{self.c2}"
end

#to_xml(name = nil) ⇒ Object



726
727
728
729
730
731
732
733
734
735
736
737
738
# File 'lib/voruby/stc/1.30/stc.rb', line 726

def to_xml(name=nil)
  el = super(name)
  
  el.add_element(self.c1.to_xml('C1')) if self.c1
  el.add_element(self.c2.to_xml('C2')) if self.c2
  
  el.attributes["#{obj_ns.prefix}:unit"] = self.unit.to_s if self.unit
  el.attributes["#{obj_ns.prefix}:vel_time_unit"] = self.vel_time_unit.to_s if self.vel_time_unit
  el.attributes["#{obj_ns.prefix}:gen_unit"] = self.gen_unit.to_s if self.gen_unit
  
  collapse_namespaces(el)
  el
end