Class: VORuby::STC::V1_10::Coords::AstroCoordsFile

Inherits:
Object
  • Object
show all
Includes:
SerializableToXml
Defined in:
lib/voruby/stc/1.10/coords.rb

Overview

Coordinate references to a specific FITS file

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(options = {}) ⇒ AstroCoordsFile

Returns a new instance of AstroCoordsFile.



1898
1899
1900
1901
# File 'lib/voruby/stc/1.10/coords.rb', line 1898

def initialize(options={})
  raise_argument_required_error('file') if !options.has_key?(:file)
  options.each { |key, value| send("#{key}=", value) }
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



1896
1897
1898
# File 'lib/voruby/stc/1.10/coords.rb', line 1896

def file
  @file
end

#positionObject

Returns the value of attribute position.



1896
1897
1898
# File 'lib/voruby/stc/1.10/coords.rb', line 1896

def position
  @position
end

#redshiftObject

Returns the value of attribute redshift.



1896
1897
1898
# File 'lib/voruby/stc/1.10/coords.rb', line 1896

def redshift
  @redshift
end

#spectralObject

Returns the value of attribute spectral.



1896
1897
1898
# File 'lib/voruby/stc/1.10/coords.rb', line 1896

def spectral
  @spectral
end

#timeObject

Returns the value of attribute time.



1896
1897
1898
# File 'lib/voruby/stc/1.10/coords.rb', line 1896

def time
  @time
end

#velocityObject

Returns the value of attribute velocity.



1896
1897
1898
# File 'lib/voruby/stc/1.10/coords.rb', line 1896

def velocity
  @velocity
end

Class Method Details

.from_xml(xml) ⇒ Object



1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
# File 'lib/voruby/stc/1.10/coords.rb', line 1949

def self.from_xml(xml)
  root = element_from(xml)
  
  options = {
    :file => Fits.from_xml(REXML::XPath.first(root, 'x:FITSFile', {'x' => obj_ns.uri})),
  }
  
  time = REXML::XPath.first(root, 'x:FITSTime', {'x' => obj_ns.uri})
  options[:time] = CoordFitsColumns.from_xml(time) if time
  
  position = REXML::XPath.first(root, 'x:FITSPosition', {'x' => obj_ns.uri})
  options[:position] = CoordFitsColumns.from_xml(position) if position
  
  velocity = REXML::XPath.first(root, 'x:FITSVelocity', {'x' => obj_ns.uri})
  options[:velocity] = CoordFitsColumns.from_xml(velocity) if velocity
  
  spectral = REXML::XPath.first(root, 'x:FITSSpectral', {'x' => obj_ns.uri})
  options[:spectral] = CoordFitsColumns.from_xml(spectral) if spectral
  
  redshift = REXML::XPath.first(root, 'x:FITSRedshift', {'x' => obj_ns.uri})
  options[:redshift] = CoordFitsColumns.from_xml(redshift) if redshift
  
  AstroCoordsFile.new(options)
end

Instance Method Details

#==(c) ⇒ Object



1974
1975
1976
1977
1978
1979
1980
1981
# File 'lib/voruby/stc/1.10/coords.rb', line 1974

def ==(c)
  self.file == c.file and
  self.time == c.time and
  self.position == c.position and
  self.velocity == c.velocity and
  self.spectral == c.spectral and
  self.redshift == c.redshift
end

#to_xml(name = nil) ⇒ Object



1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
# File 'lib/voruby/stc/1.10/coords.rb', line 1934

def to_xml(name=nil)
  el = element(name)
  
  el.add_element(self.file.to_xml('FITSFile'))
  el.add_element(self.time.to_xml('FITSTime')) if self.time
  el.add_element(self.position.to_xml('FITSPosition')) if self.position
  el.add_element(self.velocity.to_xml('FITSVelocity')) if self.velocity
  el.add_element(self.spectral.to_xml('FITSSpectral')) if self.spectral
  el.add_element(self.redshift.to_xml('FITSRedshift')) if self.redshift
  
  collapse_namespaces(el)
  
  el
end