Class: VORuby::STC::V1_30::Double3Type

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

Overview

A vector of 3 doubles with separated components.

Direct Known Subclasses

Size3Type, Value3

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, c3, options = {}) ⇒ Double3Type

Returns a new instance of Double3Type.



772
773
774
775
776
777
# File 'lib/voruby/stc/1.30/stc.rb', line 772

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

Instance Attribute Details

#c1Object

Returns the value of attribute c1.



770
771
772
# File 'lib/voruby/stc/1.30/stc.rb', line 770

def c1
  @c1
end

#c2Object

Returns the value of attribute c2.



770
771
772
# File 'lib/voruby/stc/1.30/stc.rb', line 770

def c2
  @c2
end

#c3Object

Returns the value of attribute c3.



770
771
772
# File 'lib/voruby/stc/1.30/stc.rb', line 770

def c3
  @c3
end

#gen_unitObject

Returns the value of attribute gen_unit.



770
771
772
# File 'lib/voruby/stc/1.30/stc.rb', line 770

def gen_unit
  @gen_unit
end

#unitObject

Returns the value of attribute unit.



770
771
772
# File 'lib/voruby/stc/1.30/stc.rb', line 770

def unit
  @unit
end

#vel_time_unitObject

Returns the value of attribute vel_time_unit.



770
771
772
# File 'lib/voruby/stc/1.30/stc.rb', line 770

def vel_time_unit
  @vel_time_unit
end

Class Method Details

.double3_from_xml(root) ⇒ Object



856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
# File 'lib/voruby/stc/1.30/stc.rb', line 856

def self.double3_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})
  c3_el = REXML::XPath.first(root, 'x:C3', {'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,
    c3_el ? Double1Type.from_xml(c3_el) : nil,
    options
  ]
end

.from_xml(xml) ⇒ Object



880
881
882
883
# File 'lib/voruby/stc/1.30/stc.rb', line 880

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

Instance Method Details

#==(d) ⇒ Object



827
828
829
830
831
832
833
834
835
# File 'lib/voruby/stc/1.30/stc.rb', line 827

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

#to_sObject



852
853
854
# File 'lib/voruby/stc/1.30/stc.rb', line 852

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

#to_xml(name = nil) ⇒ Object



837
838
839
840
841
842
843
844
845
846
847
848
849
850
# File 'lib/voruby/stc/1.30/stc.rb', line 837

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.add_element(self.c3.to_xml('C3')) if self.c3
  
  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