Class: VORuby::STC::V1_10::Coords::Fits

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

Overview

Specifies a FITS file and optionally a specific HDU by HDU number or HDU name

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(options = {}) ⇒ Fits

Returns a new instance of Fits.



1724
1725
1726
1727
# File 'lib/voruby/stc/1.10/coords.rb', line 1724

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

Instance Attribute Details

#hdu_nameObject

Returns the value of attribute hdu_name.



1722
1723
1724
# File 'lib/voruby/stc/1.10/coords.rb', line 1722

def hdu_name
  @hdu_name
end

#hdu_numObject

Returns the value of attribute hdu_num.



1722
1723
1724
# File 'lib/voruby/stc/1.10/coords.rb', line 1722

def hdu_num
  @hdu_num
end

#uriObject

Returns the value of attribute uri.



1722
1723
1724
# File 'lib/voruby/stc/1.10/coords.rb', line 1722

def uri
  @uri
end

Class Method Details

.from_xml(xml) ⇒ Object



1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
# File 'lib/voruby/stc/1.10/coords.rb', line 1753

def self.from_xml(xml)
  root = element_from(xml)

  options = {
   :uri => URI.parse(root.text)
  }
  hdu_num = root.attributes.get_attribute_ns(obj_ns.uri, 'hdu_num')
  options[:hdu_num] = hdu_num.value.to_i if hdu_num
  hdu_name = root.attributes.get_attribute_ns(obj_ns.uri, 'hdu_name')
  options[:hdu_name] = hdu_name.value if hdu_name
  
  Fits.new(options)
end

Instance Method Details

#==(f) ⇒ Object



1767
1768
1769
1770
1771
# File 'lib/voruby/stc/1.10/coords.rb', line 1767

def ==(f)
  self.uri == f.uri and
  self.hdu_num == f.hdu_num and
  self.hdu_name == f.hdu_name
end

#to_xml(name = 'FITSFile') ⇒ Object



1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
# File 'lib/voruby/stc/1.10/coords.rb', line 1741

def to_xml(name='FITSFile')
  el = element(name)
  
  el.text = self.uri.to_s
  el.attributes["#{obj_ns.prefix}:hdu_num"] = self.hdu_num.to_s if self.hdu_num
  el.attributes["#{obj_ns.prefix}:hdu_name"] = self.hdu_name if self.hdu_name
  
  collapse_namespaces(el)
  
  el
end