Class: VORuby::STC::V1_10::STC::TimeFrameType
- Inherits:
-
CoordFrameType
- Object
- CoordFrameType
- VORuby::STC::V1_10::STC::TimeFrameType
- Defined in:
- lib/voruby/stc/1.10/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
Instance Attribute Summary collapse
-
#reference_position ⇒ Object
Returns the value of attribute reference_position.
-
#time_ref_direction ⇒ Object
Returns the value of attribute time_ref_direction.
Attributes inherited from CoordFrameType
Class Method Summary collapse
Instance Method Summary collapse
- #==(f) ⇒ Object
-
#initialize(options = {}) ⇒ TimeFrameType
constructor
A new instance of TimeFrameType.
- #time_scale ⇒ Object
-
#time_scale=(s) ⇒ Object
The time reference frame consists of a time scale, a time format, and a reference time, if needed.
- #to_xml(name = nil) ⇒ Object
Methods included from SerializableToXml
Constructor Details
#initialize(options = {}) ⇒ TimeFrameType
Returns a new instance of TimeFrameType.
1185 1186 1187 1188 |
# File 'lib/voruby/stc/1.10/stc.rb', line 1185 def initialize(={}) raise_argument_error('reference position') if !.has_key?(:reference_position) super() end |
Instance Attribute Details
#reference_position ⇒ Object
Returns the value of attribute reference_position.
1183 1184 1185 |
# File 'lib/voruby/stc/1.10/stc.rb', line 1183 def reference_position @reference_position end |
#time_ref_direction ⇒ Object
Returns the value of attribute time_ref_direction.
1183 1184 1185 |
# File 'lib/voruby/stc/1.10/stc.rb', line 1183 def time_ref_direction @time_ref_direction end |
Class Method Details
.from_xml(xml) ⇒ Object
1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 |
# File 'lib/voruby/stc/1.10/stc.rb', line 1241 def self.from_xml(xml) root = element_from(xml) = { :reference_position => xml_to_obj(root, ReferencePosition, true), :time_scale => TimeScale.new(REXML::XPath.first(root, 'x:TimeScale', {'x' => obj_ns.uri}).text) } name = REXML::XPath.first(root, 'x:Name', {'x' => obj_ns.uri}) [:name] = name.text if name time_ref_dir = REXML::XPath.first(root, 'x:TimeRefDirection', {'x' => obj_ns.uri}) [:time_ref_direction] = AstroCoords.from_xml(time_ref_dir) if time_ref_dir self.new() end |
Instance Method Details
#==(f) ⇒ Object
1217 1218 1219 1220 1221 1222 |
# File 'lib/voruby/stc/1.10/stc.rb', line 1217 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 |
#time_scale ⇒ Object
1199 1200 1201 |
# File 'lib/voruby/stc/1.10/stc.rb', line 1199 def time_scale @time_scale || TimeScale.new('TT') end |
#time_scale=(s) ⇒ Object
The time reference frame consists of a time scale, a time format, and a reference time, if needed
1191 1192 1193 1194 1195 1196 1197 |
# File 'lib/voruby/stc/1.10/stc.rb', line 1191 def time_scale=(s) if s s = TimeScale.new(s) if s.is_a?(String) raise_type_mismatch_error(s, TimeScale) end @time_scale = s end |
#to_xml(name = nil) ⇒ Object
1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 |
# File 'lib/voruby/stc/1.10/stc.rb', line 1224 def to_xml(name=nil) el = super(name) coords_ns = NAMESPACES['VORuby::STC::V1_10::Coords'] el.add_namespace(coords_ns.prefix, coords_ns.uri) time_scale = REXML::Element.new("#{obj_ns.prefix}:TimeScale") time_scale.text = self.time_scale.to_s el.add_element(time_scale) el.add_element(self.reference_position.to_xml) el.add_element(self.time_ref_direction.to_xml('TimeRefDirection', obj_ns)) if self.time_ref_direction collapse_namespaces(el) el end |