Class: VORuby::STC::V1_30::FitsType

Inherits:
Object
  • Object
show all
Includes:
SerializableToXml
Defined in:
lib/voruby/stc/1.30/stc.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(uri, options = {}) ⇒ FitsType

Returns a new instance of FitsType.



3058
3059
3060
3061
# File 'lib/voruby/stc/1.30/stc.rb', line 3058

def initialize(uri, options={})
  self.value = uri
  options.each { |key, value| send("#{key}=", value) }
end

Instance Attribute Details

#hdu_nameObject

Returns the value of attribute hdu_name.



3056
3057
3058
# File 'lib/voruby/stc/1.30/stc.rb', line 3056

def hdu_name
  @hdu_name
end

#hdu_numObject

Returns the value of attribute hdu_num.



3056
3057
3058
# File 'lib/voruby/stc/1.30/stc.rb', line 3056

def hdu_num
  @hdu_num
end

#valueObject

Returns the value of attribute value.



3056
3057
3058
# File 'lib/voruby/stc/1.30/stc.rb', line 3056

def value
  @value
end

Class Method Details

.from_xml(xml) ⇒ Object



3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
# File 'lib/voruby/stc/1.30/stc.rb', line 3092

def self.from_xml(xml)
  root = element_from(xml)
  
  options = {}
  
  hnum = root.attributes.get_attribute_ns(obj_ns.uri, 'hdu_num')
  options[:hdu_num] = Integer(hnum.value) if hnum
  
  hname = root.attributes.get_attribute_ns(obj_ns.uri, 'hdu_name')
  options[:hdu_name] = hname.value if hname
  
  self.new(URI.parse(root.texts.join('').strip), options)
end

Instance Method Details

#==(f) ⇒ Object



3076
3077
3078
3079
3080
# File 'lib/voruby/stc/1.30/stc.rb', line 3076

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

#to_xml(name = nil) ⇒ Object



3082
3083
3084
3085
3086
3087
3088
3089
3090
# File 'lib/voruby/stc/1.30/stc.rb', line 3082

def to_xml(name=nil)
  el = element(name)
  
  el.text = self.value.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
  
  el
end