Class: VORuby::STC::V1_10::Coords::CoordFitsColumns

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

Overview

Refers coordinate components to specific columns in the FITS file HDU

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(options = {}) ⇒ CoordFitsColumns

Returns a new instance of CoordFitsColumns.



1780
1781
1782
1783
# File 'lib/voruby/stc/1.10/coords.rb', line 1780

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

Instance Attribute Details

#errorObject

Returns the value of attribute error.



1778
1779
1780
# File 'lib/voruby/stc/1.10/coords.rb', line 1778

def error
  @error
end

#nameObject

Returns the value of attribute name.



1778
1779
1780
# File 'lib/voruby/stc/1.10/coords.rb', line 1778

def name
  @name
end

#pix_sizeObject

Returns the value of attribute pix_size.



1778
1779
1780
# File 'lib/voruby/stc/1.10/coords.rb', line 1778

def pix_size
  @pix_size
end

#resolutionObject

Returns the value of attribute resolution.



1778
1779
1780
# File 'lib/voruby/stc/1.10/coords.rb', line 1778

def resolution
  @resolution
end

#sizeObject

Returns the value of attribute size.



1778
1779
1780
# File 'lib/voruby/stc/1.10/coords.rb', line 1778

def size
  @size
end

#valueObject

Returns the value of attribute value.



1778
1779
1780
# File 'lib/voruby/stc/1.10/coords.rb', line 1778

def value
  @value
end

Class Method Details

.from_xml(xml) ⇒ Object



1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
# File 'lib/voruby/stc/1.10/coords.rb', line 1857

def self.from_xml(xml)
  root = element_from(xml)
  
  options = {
    :name => REXML::XPath.first(root, 'x:Name', {'x' => obj_ns.uri}).text
  }
  
  value = REXML::XPath.first(root, 'x:Value', {'x' => obj_ns.uri})
  options[:value] = value.text if value
  
  error = REXML::XPath.first(root, 'x:Error', {'x' => obj_ns.uri})
  options[:error] = error.text if error
  
  resolution = REXML::XPath.first(root, 'x:Resolution', {'x' => obj_ns.uri})
  options[:resolution] = resolution.text if resolution
  
  size = REXML::XPath.first(root, 'x:Size', {'x' => obj_ns.uri})
  options[:size] = size.text if size
  
  pix_size = REXML::XPath.first(root, 'x:PixSize', {'x' => obj_ns.uri})
  options[:pix_size] = pix_size.text if pix_size
  
  CoordFitsColumns.new(options)
end

Instance Method Details

#==(c) ⇒ Object



1882
1883
1884
1885
1886
1887
1888
1889
# File 'lib/voruby/stc/1.10/coords.rb', line 1882

def ==(c)
  self.name == c.name and
  self.value == c.value and
  self.error == c.error and
  self.resolution == c.resolution and
  self.size == c.size and
  self.pix_size == c.pix_size
end

#to_xml(name) ⇒ Object



1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
# File 'lib/voruby/stc/1.10/coords.rb', line 1815

def to_xml(name)
  el = element(name)
  
  name = REXML::Element.new("#{obj_ns.prefix}:Name")
  name.text = self.name
  el.add_element(name)
  
  if self.value
    value = REXML::Element.new("#{obj_ns.prefix}:Value")
    value.text = self.value
    el.add_element(value)
  end
  
  if self.error
    error = REXML::Element.new("#{obj_ns.prefix}:Error")
    error.text = self.error
    el.add_element(error)
  end
  
  if self.resolution
    res = REXML::Element.new("#{obj_ns.prefix}:Resolution")
    res.text = self.resolution
    el.add_element(res)
  end
  
  if self.size
    size = REXML::Element.new("#{obj_ns.prefix}:Size")
    size.text = self.size
    el.add_element(size)
  end
  
  if self.pix_size
    pix_size = REXML::Element.new("#{obj_ns.prefix}:PixSize")
    pix_size.text = self.pix_size
    el.add_element(pix_size)
  end
  
  collapse_namespaces(el)
  
  el
end