Class: VORuby::STC::V1_10::STC::RedshiftFrameType

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

Overview

Contains the Doppler definitions, including whether the values are velocity or redshift (value_type)

Direct Known Subclasses

RedshiftFrame

Instance Attribute Summary collapse

Attributes inherited from CoordFrameType

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(options = {}) ⇒ RedshiftFrameType

Returns a new instance of RedshiftFrameType.



1321
1322
1323
1324
# File 'lib/voruby/stc/1.10/stc.rb', line 1321

def initialize(options={})
  raise_argument_required_error('reference position') if !options.has_key?(:reference_position)
  super(options)
end

Instance Attribute Details

#doppler_definitionObject

Returns the value of attribute doppler_definition.



1319
1320
1321
# File 'lib/voruby/stc/1.10/stc.rb', line 1319

def doppler_definition
  @doppler_definition
end

#reference_positionObject

Returns the value of attribute reference_position.



1319
1320
1321
# File 'lib/voruby/stc/1.10/stc.rb', line 1319

def reference_position
  @reference_position
end

Class Method Details

.from_xml(xml) ⇒ Object



1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
# File 'lib/voruby/stc/1.10/stc.rb', line 1374

def self.from_xml(xml)
  root = element_from(xml)
  
  options = {
    :reference_position => xml_to_obj(root, ReferencePosition, true),
  }
  
  name = REXML::XPath.first(root, 'x:Name', {'x' => obj_ns.uri})
  options[:name] = name.text if name
  
  value_type = root.attributes.get_attribute_ns(obj_ns.uri, 'value_type')
  options[:value_type] = value_type.value if value_type
  
  doppler_def = REXML::XPath.first(root, 'x:DopplerDefinition', {'x' => obj_ns.uri})
  options[:doppler_definition] = DopplerDefinition.new(doppler_def.text) if doppler_def
  
  self.new(options)
end

Instance Method Details

#==(f) ⇒ Object



1350
1351
1352
1353
1354
1355
# File 'lib/voruby/stc/1.10/stc.rb', line 1350

def ==(f)
  super(f) and
  self.doppler_definition == f.doppler_definition and
  self.reference_position == f.reference_position and
  self.value_type == f.value_type
end

#to_xml(name = nil) ⇒ Object



1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
# File 'lib/voruby/stc/1.10/stc.rb', line 1357

def to_xml(name=nil)
  el = super(name)
  
  el.attributes["#{obj_ns.prefix}:value_type"] = self.value_type
  
  if self.doppler_definition
    doppler = REXML::Element.new("#{obj_ns.prefix}:DopplerDefinition")
    doppler.text = doppler_definition.value
    el.add_element(doppler)
  end
  
  el.add_element(self.reference_position.to_xml)
  
  collapse_namespaces(el)
  el
end

#value_typeObject



1346
1347
1348
# File 'lib/voruby/stc/1.10/stc.rb', line 1346

def value_type
  @value_type || 'VELOCITY'
end

#value_type=(v) ⇒ Object



1342
1343
1344
# File 'lib/voruby/stc/1.10/stc.rb', line 1342

def value_type=(v)
  @value_type = v ? v.to_s : nil
end