Class: VORuby::STC::V1_30::Double4Type

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

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(m11, m12, m21, m22, options = {}) ⇒ Double4Type

Returns a new instance of Double4Type.



890
891
892
893
894
895
896
# File 'lib/voruby/stc/1.30/stc.rb', line 890

def initialize(m11, m12, m21, m22, options={})
  self.m11 = m11
  self.m12 = m12
  self.m21 = m21
  self.m22 = m22
  super(options)
end

Instance Attribute Details

#gen_unitObject

Returns the value of attribute gen_unit.



887
888
889
# File 'lib/voruby/stc/1.30/stc.rb', line 887

def gen_unit
  @gen_unit
end

#m11Object

Returns the value of attribute m11.



887
888
889
# File 'lib/voruby/stc/1.30/stc.rb', line 887

def m11
  @m11
end

#m12Object

Returns the value of attribute m12.



887
888
889
# File 'lib/voruby/stc/1.30/stc.rb', line 887

def m12
  @m12
end

#m21Object

Returns the value of attribute m21.



887
888
889
# File 'lib/voruby/stc/1.30/stc.rb', line 887

def m21
  @m21
end

#m22Object

Returns the value of attribute m22.



887
888
889
# File 'lib/voruby/stc/1.30/stc.rb', line 887

def m22
  @m22
end

#unitObject

Returns the value of attribute unit.



887
888
889
# File 'lib/voruby/stc/1.30/stc.rb', line 887

def unit
  @unit
end

#vel_time_unitObject

Returns the value of attribute vel_time_unit.



887
888
889
# File 'lib/voruby/stc/1.30/stc.rb', line 887

def vel_time_unit
  @vel_time_unit
end

Class Method Details

.from_xml(xml) ⇒ Object



988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
# File 'lib/voruby/stc/1.30/stc.rb', line 988

def self.from_xml(xml)
  root = element_from(xml)
  
  m11_el = REXML::XPath.first(root, 'x:M11', {'x' => obj_ns.uri})
  m12_el = REXML::XPath.first(root, 'x:M12', {'x' => obj_ns.uri})
  m21_el = REXML::XPath.first(root, 'x:M21', {'x' => obj_ns.uri})
  m22_el = REXML::XPath.first(root, 'x:M22', {'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
  
  self.new(
    (m11_el and m11_el.text) ? Float(m11_el.text) : nil,
    (m12_el and m12_el.text) ? Float(m12_el.text) : nil,
    (m21_el and m21_el.text) ? Float(m21_el.text) : nil,
    (m22_el and m22_el.text) ? Float(m22_el.text) : nil,
    options
  )
end

Instance Method Details

#==(d) ⇒ Object



938
939
940
941
942
943
944
945
946
947
# File 'lib/voruby/stc/1.30/stc.rb', line 938

def ==(d)
  super(d) and
  self.m11 == d.m11 and
  self.m12 == d.m12 and
  self.m21 == d.m21 and
  self.m22 == d.m22 and
  self.unit == d.unit and
  self.vel_time_unit == d.vel_time_unit and
  self.gen_unit == d.gen_unit
end

#to_sObject



984
985
986
# File 'lib/voruby/stc/1.30/stc.rb', line 984

def to_s
  "#{self.m11} #{self.m12} #{self.m21} #{self.m22}"
end

#to_xml(name = nil) ⇒ Object



949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
# File 'lib/voruby/stc/1.30/stc.rb', line 949

def to_xml(name=nil)
  el = super(name)
  
  if self.m11
    m11_el = REXML::Element.new("#{obj_ns.prefix}:M11")
    m11_el.text = self.m11.to_s
    el.add_element(m11_el)
  end
  
  if self.m12
    m12_el = REXML::Element.new("#{obj_ns.prefix}:M12")
    m12_el.text = self.m12.to_s
    el.add_element(m12_el)
  end
  
  if self.m21
    m21_el = REXML::Element.new("#{obj_ns.prefix}:M21")
    m21_el.text = self.m21.to_s
    el.add_element(m21_el)
  end
  
  if self.m22
    m22_el = REXML::Element.new("#{obj_ns.prefix}:M22")
    m22_el.text = self.m22.to_s
    el.add_element(m22_el)
  end
  
  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