Class: VORuby::STC::V1_30::Double1Type

Inherits:
Object
  • Object
show all
Includes:
STCReference
Defined in:
lib/voruby/stc/1.30/stc.rb

Overview

A double with referencing and units attributes

Instance Attribute Summary collapse

Attributes included from STCReference

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from STCReference

#stc_reference_eq, stc_reference_from_xml, #stc_reference_to_xml

Methods included from SerializableToXml

#element

Constructor Details

#initialize(value, options = {}) ⇒ Double1Type

Returns a new instance of Double1Type.



552
553
554
555
# File 'lib/voruby/stc/1.30/stc.rb', line 552

def initialize(value, options={})
  self.value = value
  options.each { |key, v| send("#{key}=", v) }
end

Instance Attribute Details

#gen_unitObject

Returns the value of attribute gen_unit.



549
550
551
# File 'lib/voruby/stc/1.30/stc.rb', line 549

def gen_unit
  @gen_unit
end

#pos_angle_unitObject

Returns the value of attribute pos_angle_unit.



549
550
551
# File 'lib/voruby/stc/1.30/stc.rb', line 549

def pos_angle_unit
  @pos_angle_unit
end

#pos_unitObject

Returns the value of attribute pos_unit.



549
550
551
# File 'lib/voruby/stc/1.30/stc.rb', line 549

def pos_unit
  @pos_unit
end

#spectral_unitObject

Returns the value of attribute spectral_unit.



549
550
551
# File 'lib/voruby/stc/1.30/stc.rb', line 549

def spectral_unit
  @spectral_unit
end

#time_unitObject

Returns the value of attribute time_unit.



549
550
551
# File 'lib/voruby/stc/1.30/stc.rb', line 549

def time_unit
  @time_unit
end

#valueObject

Returns the value of attribute value.



549
550
551
# File 'lib/voruby/stc/1.30/stc.rb', line 549

def value
  @value
end

#vel_time_unitObject

Returns the value of attribute vel_time_unit.



549
550
551
# File 'lib/voruby/stc/1.30/stc.rb', line 549

def vel_time_unit
  @vel_time_unit
end

Class Method Details

.from_xml(xml) ⇒ Object



640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
# File 'lib/voruby/stc/1.30/stc.rb', line 640

def self.from_xml(xml)
  root = element_from(xml)
  
  options = STCReference.stc_reference_from_xml(root)
  
  time_unit = root.attributes.get_attribute_ns(obj_ns.uri, 'time_unit')
  options[:time_unit] = TimeUnitType.new(time_unit.value) if time_unit
  
  pos_unit = root.attributes.get_attribute_ns(obj_ns.uri, 'pos_unit')
  options[:pos_unit] = PosUnitType.new(pos_unit.value) if pos_unit
  
  pos_angle_unit = root.attributes.get_attribute_ns(obj_ns.uri, 'pos_angle_unit')
  options[:pos_angle_unit] = AngleUnitType.new(pos_angle_unit.value) if pos_angle_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
  
  spectral_unit = root.attributes.get_attribute_ns(obj_ns.uri, 'spectral_unit')
  options[:spectral_unit] = SpectralUnitType.new(spectral_unit.value) if spectral_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(root.text ? Float(root.text) : nil, options)
end

Instance Method Details

#==(d) ⇒ Object



610
611
612
613
614
615
616
617
618
619
# File 'lib/voruby/stc/1.30/stc.rb', line 610

def ==(d)
  self.stc_reference_eq(d) and
  self.value == d.value and
  self.time_unit == d.time_unit and
  self.pos_unit == d.pos_unit and
  self.pos_angle_unit == d.pos_angle_unit and
  self.vel_time_unit == d.vel_time_unit and
  self.spectral_unit == d.spectral_unit and
  self.gen_unit == d.gen_unit
end

#to_sObject



636
637
638
# File 'lib/voruby/stc/1.30/stc.rb', line 636

def to_s
  self.value.to_s
end

#to_xml(name = nil) ⇒ Object



621
622
623
624
625
626
627
628
629
630
631
632
633
634
# File 'lib/voruby/stc/1.30/stc.rb', line 621

def to_xml(name=nil)
  el = stc_reference_to_xml(element(name))
  
  el.text = self.value.to_s if self.value
  el.attributes["#{obj_ns.prefix}:time_unit"] = self.time_unit.to_s if self.time_unit
  el.attributes["#{obj_ns.prefix}:pos_unit"] = self.pos_unit.to_s if self.pos_unit
  el.attributes["#{obj_ns.prefix}:pos_angle_unit"] = self.pos_angle_unit.to_s if self.pos_angle_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}:spectral_unit"] = self.spectral_unit.to_s if self.spectral_unit
  el.attributes["#{obj_ns.prefix}:gen_unit"] = self.gen_unit.to_s if self.gen_unit
  
  collapse_namespaces(el)
  el
end