Class: VORuby::STC::V1_30::CoordFITSColumnsType

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

Returns a new instance of CoordFITSColumnsType.



3114
3115
3116
# File 'lib/voruby/stc/1.30/stc.rb', line 3114

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

Instance Attribute Details

#errorObject

Returns the value of attribute error.



3111
3112
3113
# File 'lib/voruby/stc/1.30/stc.rb', line 3111

def error
  @error
end

#nameObject

Returns the value of attribute name.



3111
3112
3113
# File 'lib/voruby/stc/1.30/stc.rb', line 3111

def name
  @name
end

#pix_sizeObject

Returns the value of attribute pix_size.



3111
3112
3113
# File 'lib/voruby/stc/1.30/stc.rb', line 3111

def pix_size
  @pix_size
end

#resolutionObject

Returns the value of attribute resolution.



3111
3112
3113
# File 'lib/voruby/stc/1.30/stc.rb', line 3111

def resolution
  @resolution
end

#sizeObject

Returns the value of attribute size.



3111
3112
3113
# File 'lib/voruby/stc/1.30/stc.rb', line 3111

def size
  @size
end

#valueObject

Returns the value of attribute value.



3111
3112
3113
# File 'lib/voruby/stc/1.30/stc.rb', line 3111

def value
  @value
end

Class Method Details

.from_xml(xml) ⇒ Object



3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
# File 'lib/voruby/stc/1.30/stc.rb', line 3198

def self.from_xml(xml)
  root = element_from(xml)
  
  options = {}
  
  name = REXML::XPath.first(root, 'x:Name', {'x' => obj_ns.uri})
  options[:name] = name.text if name
  
  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
  
  self.new(options)
end

Instance Method Details

#==(c) ⇒ Object



3147
3148
3149
3150
3151
3152
3153
3154
# File 'lib/voruby/stc/1.30/stc.rb', line 3147

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 = nil) ⇒ Object



3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
# File 'lib/voruby/stc/1.30/stc.rb', line 3156

def to_xml(name=nil)
  el = element(name)
  
  if self.name
    name_el = REXML::Element.new("#{obj_ns.prefix}:Name")
    name_el.text = self.name
    el.add_element(name_el)
  end
  
  if self.value
    value_el = REXML::Element.new("#{obj_ns.prefix}:Value")
    value_el.text = self.value
    el.add_element(value_el)
  end
  
  if self.error
    error_el = REXML::Element.new("#{obj_ns.prefix}:Error")
    error_el.text = self.error
    el.add_element(error_el)
  end
  
  if self.resolution
    resolution_el = REXML::Element.new("#{obj_ns.prefix}:Resolution")
    resolution_el.text = self.resolution
    el.add_element(resolution_el)
  end
  
  if self.size
    size_el = REXML::Element.new("#{obj_ns.prefix}:Size")
    size_el.text = self.size
    el.add_element(size_el)
  end
  
  if self.pix_size
    pix_size_el = REXML::Element.new("#{obj_ns.prefix}:PixSize")
    pix_size_el.text = self.pix_size
    el.add_element(pix_size_el)
  end
  
  el
end