Class: VORuby::VOTables::VOTable::Meta::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/voruby/votables/meta.rb,
lib/voruby/votables/transforms.rb,
lib/voruby/votables/rexml_parser.rb,
lib/voruby/votables/libxml_parser.rb

Overview

A class representing the standard VOTable OPTION element.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value = nil, name = nil, options = []) ⇒ Option

value:

The value of the optional quantity.

name:

The name of the option.

options:

A list of suboptions (Type: Meta::Option).



695
696
697
698
699
700
701
702
703
704
705
# File 'lib/voruby/votables/meta.rb', line 695

def initialize(value=nil, name=nil, options=[])
#raise "Option must have a value" if value == nil
	
@value = value
@name = name
	
options.each{ |option|
 Misc::TypeCheck.new(option, Meta::Option).check()
}
@options = options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



687
688
689
# File 'lib/voruby/votables/meta.rb', line 687

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



687
688
689
# File 'lib/voruby/votables/meta.rb', line 687

def options
  @options
end

#valueObject (readonly)

Returns the value of attribute value.



687
688
689
# File 'lib/voruby/votables/meta.rb', line 687

def value
  @value
end

Class Method Details

.from_soap_obj(moptions) ⇒ Object



296
297
298
299
300
301
302
303
304
305
306
307
# File 'lib/voruby/votables/transforms.rb', line 296

def self.from_soap_obj(moptions)
  options = []
  moptions.each do |moption|
    options.push(Option.new(
      VOTable::_find_attr_value(mvalues.__xmlattr, 'value'),
      VOTable::_find_attr_value(mvalues.__xmlattr, 'name'),
      (moption.respond_to?(:oPTION))? Option.from_soap_obj(moption.oPTION): []
  ))
  end
        
  options
end

.from_xml(node) ⇒ Object



289
290
291
292
293
294
295
296
297
298
299
# File 'lib/voruby/votables/rexml_parser.rb', line 289

def self.from_xml(node)
value = node.attributes['value'] if node.attributes['value']
name = node.attributes['name'] if node.attributes['name']
	
options = []
node.elements.each('OPTION'){ |optNode|
 		options.push(Meta::Option.from_xml(optNode))
}
			  
return self.new(value, name, options)
end

Instance Method Details

#to_sObject



707
708
709
710
711
712
# File 'lib/voruby/votables/meta.rb', line 707

def to_s
options = @options.collect{|x| x.to_s}.join('|')
	
"{value=#{@value};name=#{@name};" +
"options=#{options}}"
end