Class: VORuby::STC::V1_10::STC::RedshiftInterval

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

Overview

Contains a 1-D redshift interval; position and time units are required if redshifts are expressed as Doppler velocities

Instance Attribute Summary collapse

Attributes inherited from CoordScalarIntervalType

#hi_limit, #lo_limit

Attributes inherited from CoordIntervalType

#hi_include, #lo_include

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CoordIntervalType

#fill_factor, #fill_factor=, #initialize

Methods included from SerializableToXml

#element

Constructor Details

This class inherits a constructor from VORuby::STC::V1_10::STC::CoordIntervalType

Instance Attribute Details

#unitObject

Returns the value of attribute unit.



2452
2453
2454
# File 'lib/voruby/stc/1.10/stc.rb', line 2452

def unit
  @unit
end

#vel_time_unitObject

Returns the value of attribute vel_time_unit.



2452
2453
2454
# File 'lib/voruby/stc/1.10/stc.rb', line 2452

def vel_time_unit
  @vel_time_unit
end

Class Method Details

.from_xml(xml) ⇒ Object



2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
# File 'lib/voruby/stc/1.10/stc.rb', line 2481

def self.from_xml(xml)
  root = element_from(xml)
  
  options = {}
  
  lo_include = root.attributes.get_attribute_ns(obj_ns.uri, 'lo_include')
  options[:lo_include] = (lo_include.value == 'true' ? true : false) if lo_include
  
  hi_include = root.attributes.get_attribute_ns(obj_ns.uri, 'hi_include')
  options[:hi_include] = (hi_include.value == 'true' ? true : false) if hi_include
  
  fill_factor = root.attributes.get_attribute_ns(obj_ns.uri, 'fill_factor')
  options[:fill_factor] = Float(fill_factor.value) if fill_factor
  
  lo_limit = REXML::XPath.first(root, 'x:LoLimit', {'x' => obj_ns.uri})
  options[:lo_limit] = Float(lo_limit.text) if lo_limit
  
  hi_limit = REXML::XPath.first(root, 'x:HiLimit', {'x' => obj_ns.uri})
  options[:hi_limit] = Float(hi_limit.text) if hi_limit
  
  unit = root.attributes.get_attribute_ns(obj_ns.uri, 'unit')
  options[:unit] = PosUnit.new(unit.value) if unit
  
  vel_time_unit = root.attributes.get_attribute_ns(obj_ns.uri, 'vel_time_unit')
  options[:vel_time_unit] = VelTimeUnit.new(vel_time_unit.value) if vel_time_unit
  
  self.new(options)
end

Instance Method Details

#==(i) ⇒ Object



2466
2467
2468
2469
2470
# File 'lib/voruby/stc/1.10/stc.rb', line 2466

def ==(i)
  super(i) and
  self.unit == i.unit and
  self.vel_time_unit == i.vel_time_unit
end

#to_xml(name = nil) ⇒ Object



2472
2473
2474
2475
2476
2477
2478
2479
# File 'lib/voruby/stc/1.10/stc.rb', line 2472

def to_xml(name=nil)
  el = super(name)
  
  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
end