Class: VORuby::VOTable::V1_1::Option

Inherits:
Base show all
Defined in:
lib/voruby/votable/1.1/votable.rb

Overview

An enumeration of possible values. Essentially a hierarchy of key-value pairs.

Constant Summary collapse

ELEMENT_NAME =
'OPTION'

Instance Attribute Summary

Attributes inherited from XML::Object::Base

#node

Instance Method Summary collapse

Methods inherited from Base

#==, element_name, #get_element, #xpath_for

Methods inherited from XML::Object::Base

#==, element_name, from_file, #to_s

Constructor Details

#initialize(defn = nil) ⇒ Option

Create a new enumeration.

option = Option.new(
  :name => 'authors',
  :options => [
    Option.new(:name =>  'last_name', :value => 'Gasson'),
    Option.new(:name => 'last_name', :value => 'Miller')
   ]
)


1475
1476
1477
# File 'lib/voruby/votable/1.1/votable.rb', line 1475

def initialize(defn=nil)
  super(defn)
end

Instance Method Details

#nameObject



1479
1480
1481
# File 'lib/voruby/votable/1.1/votable.rb', line 1479

def name
  self.node['name']
end

#name=(n) ⇒ Object



1483
1484
1485
# File 'lib/voruby/votable/1.1/votable.rb', line 1483

def name=(n)
  @node['name'] = n.to_s
end

#optionsObject

Retrieve any sub-options (Option). Returns a HomogeneousNodeList.



1497
1498
1499
# File 'lib/voruby/votable/1.1/votable.rb', line 1497

def options
  HomogeneousNodeList.new(self.node, xpath_for(Option), Option)
end

#options=(opts) ⇒ Object

Set any sub-options. option.options = [Option.new(), …]



1503
1504
1505
# File 'lib/voruby/votable/1.1/votable.rb', line 1503

def options=(opts)
  self.options.replace(opts)
end

#valueObject



1487
1488
1489
# File 'lib/voruby/votable/1.1/votable.rb', line 1487

def value
  self.node['value']
end

#value=(v) ⇒ Object



1491
1492
1493
# File 'lib/voruby/votable/1.1/votable.rb', line 1491

def value=(v)
  @node['value'] = v.to_s
end