Class: VORuby::STC::V1_30::TimeFrameType

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

Overview

The time reference frame consists of a timescale, a reference position, and optionally a reference direction (needed when transformations have been applied).

Direct Known Subclasses

TimeFrame

Instance Attribute Summary collapse

Attributes inherited from CoordFrameType

#name

Attributes included from STCReference

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CoordFrameType

coord_frame_from_xml

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(reference_position, time_scale = TimeScaleType.new('TT'), time_ref_direction = nil, name = nil, options = {}) ⇒ TimeFrameType

Returns a new instance of TimeFrameType.



7731
7732
7733
7734
7735
7736
# File 'lib/voruby/stc/1.30/stc.rb', line 7731

def initialize(reference_position, time_scale=TimeScaleType.new('TT'), time_ref_direction=nil, name=nil, options={})
  super(name, options)
  self.time_scale = time_scale || TimeScaleType.new('TT')
  self.reference_position = reference_position
  self.time_ref_direction = time_ref_direction
end

Instance Attribute Details

#reference_positionObject

Returns the value of attribute reference_position.



7729
7730
7731
# File 'lib/voruby/stc/1.30/stc.rb', line 7729

def reference_position
  @reference_position
end

#time_ref_directionObject

Returns the value of attribute time_ref_direction.



7729
7730
7731
# File 'lib/voruby/stc/1.30/stc.rb', line 7729

def time_ref_direction
  @time_ref_direction
end

#time_scaleObject

Returns the value of attribute time_scale.



7729
7730
7731
# File 'lib/voruby/stc/1.30/stc.rb', line 7729

def time_scale
  @time_scale
end

Class Method Details

.from_xml(xml) ⇒ Object



7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
# File 'lib/voruby/stc/1.30/stc.rb', line 7781

def self.from_xml(xml)
  root = element_from(xml)
  
  ts = REXML::XPath.first(root, 'x:TimeScale', {'x' => obj_ns.uri})
  trd = REXML::XPath.first(root, 'x:TimeRefDirection', {'x' => obj_ns.uri})
  
  self.new(
    xml_to_obj(root, ReferencePosition, true),
    ts ? TimeScaleType.new(ts.text) : nil,
    trd ? AstroCoordsType.from_xml(trd) : nil,
    *CoordFrameType.coord_frame_from_xml(root)
  )
end

Instance Method Details

#==(f) ⇒ Object



7758
7759
7760
7761
7762
7763
# File 'lib/voruby/stc/1.30/stc.rb', line 7758

def ==(f)
  super(f) and
  self.time_scale == f.time_scale and
  self.reference_position == f.reference_position and
  self.time_ref_direction == f.time_ref_direction
end

#to_xml(name = nil) ⇒ Object



7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
# File 'lib/voruby/stc/1.30/stc.rb', line 7765

def to_xml(name=nil)
  el = super(name)
  
  if self.time_scale
    ts = REXML::Element.new("#{obj_ns.prefix}:TimeScale")
    ts.text = self.time_scale.to_s
    el.add_element(ts)
  end
  
  el.add_element(self.reference_position.to_xml)
  el.add_element(self.time_ref_direction.to_xml('TimeRefDirection')) if self.time_ref_direction
  
  collapse_namespaces(el)
  el
end