Class: VORuby::VOTables::VOTable::Meta::Param
- 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 PARAM group.
Instance Attribute Summary collapse
-
#arraysize ⇒ Object
readonly
Returns the value of attribute arraysize.
-
#datatype ⇒ Object
readonly
Returns the value of attribute datatype.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#precision ⇒ Object
readonly
Returns the value of attribute precision.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
-
#ucd ⇒ Object
readonly
Returns the value of attribute ucd.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
-
#uType ⇒ Object
readonly
Returns the value of attribute uType.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name = nil, datatype = nil, value = nil, ucd = nil, unit = nil, description = nil, values = nil, links = [], id = nil, precision = nil, utype = nil, width = nil, ref = nil, arraysize = nil) ⇒ Param
constructor
- name:
-
The name of the parameter.
- #to_s ⇒ Object
Constructor Details
#initialize(name = nil, datatype = nil, value = nil, ucd = nil, unit = nil, description = nil, values = nil, links = [], id = nil, precision = nil, utype = nil, width = nil, ref = nil, arraysize = nil) ⇒ Param
- name:
-
The name of the parameter.
- datatype:
-
The datatype of the parameter (Type: Type::DataType).
- value:
-
The value of the parameter.
- ucd:
-
The UCD of the parameter (Type: Type::UCDType).
- unit:
-
The units of the value.
- description:
-
A description of the parameter (Type: VOTALE::Meta::Description).
- values:
-
Domain values for the parameter (Type: Meta::Values).
- links:
-
A collection of links associated with the parameter (Type: VOTable:Meta::Values).
- id:
-
A unique identifier for the parameter.
- precision:
-
The precision of the parameter (Type: Meta::PrecisionType).
- utype:
-
The unique type of the parameter.
- width:
-
The number of characters to use for input or output (Type: Type::PositiveInteger).
- ref:
-
A reference to another parameter.
- arraysize:
-
The arraysize definition for the parameter (Type: Type::ArrayDef).
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/voruby/votables/meta.rb', line 331 def initialize(name=nil, datatype=nil, value=nil, ucd=nil, unit=nil, description=nil, values=nil, links=[], id=nil, precision=nil, utype=nil, width=nil, ref=nil, arraysize=nil) #raise "Param must define a data Type" if datatype == nil raise "Param must define a name" if name == nil #raise "Param must define a value" if value == nil @name = name Misc::TypeCheck.new(datatype, Type::DataType).check() @datatype = datatype @value = value Misc::TypeCheck.new(ucd, Type::UCDType).check() @ucd = ucd @unit = unit Misc::TypeCheck.new(description, Meta::Description).check() @description = description Misc::TypeCheck.new(values, Meta::Values).check() @values = values links.each{ |link| Misc::TypeCheck.new(link, Meta::Link).check() } @links = links @id = id Misc::TypeCheck.new(precision, Type::PrecisionType).check() @precision = precision @utype = utype Misc::TypeCheck.new(width, Type::PositiveInteger).check() @width = width @ref = ref Misc::TypeCheck.new(arraysize, Type::ArrayDef).check() @arraysize = arraysize end |
Instance Attribute Details
#arraysize ⇒ Object (readonly)
Returns the value of attribute arraysize.
299 300 301 |
# File 'lib/voruby/votables/meta.rb', line 299 def arraysize @arraysize end |
#datatype ⇒ Object (readonly)
Returns the value of attribute datatype.
299 300 301 |
# File 'lib/voruby/votables/meta.rb', line 299 def datatype @datatype end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
299 300 301 |
# File 'lib/voruby/votables/meta.rb', line 299 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
299 300 301 |
# File 'lib/voruby/votables/meta.rb', line 299 def id @id end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
299 300 301 |
# File 'lib/voruby/votables/meta.rb', line 299 def links @links end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
299 300 301 |
# File 'lib/voruby/votables/meta.rb', line 299 def name @name end |
#precision ⇒ Object (readonly)
Returns the value of attribute precision.
299 300 301 |
# File 'lib/voruby/votables/meta.rb', line 299 def precision @precision end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
299 300 301 |
# File 'lib/voruby/votables/meta.rb', line 299 def ref @ref end |
#ucd ⇒ Object (readonly)
Returns the value of attribute ucd.
299 300 301 |
# File 'lib/voruby/votables/meta.rb', line 299 def ucd @ucd end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
299 300 301 |
# File 'lib/voruby/votables/meta.rb', line 299 def unit @unit end |
#uType ⇒ Object (readonly)
Returns the value of attribute uType.
299 300 301 |
# File 'lib/voruby/votables/meta.rb', line 299 def uType @uType end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
299 300 301 |
# File 'lib/voruby/votables/meta.rb', line 299 def value @value end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
299 300 301 |
# File 'lib/voruby/votables/meta.rb', line 299 def values @values end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
299 300 301 |
# File 'lib/voruby/votables/meta.rb', line 299 def width @width end |
Class Method Details
.from_soap_obj(mparams) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/voruby/votables/transforms.rb', line 59 def self.from_soap_obj(mparams) mparams = [mparams] if !mparams.respond_to?(:each) params = [] mparams.each do |mparam| datatype_txt = VOTable::_find_attr_value(mparam.__xmlattr, 'datatype') ucd_txt = VOTable::_find_attr_value(mparam.__xmlattr, 'ucd') precision_txt = VOTable::_find_attr_value(mparam.__xmlattr, 'precision') width_txt = VOTable::_find_attr_value(mparam.__xmlattr, 'width') arraysize_txt = VOTable::_find_attr_value(mparam.__xmlattr, 'arraysize') params.push(Param.new( VOTable::_find_attr_value(mparam.__xmlattr, 'name'), (datatype_txt == nil)? nil: Type::DataType.new(datatype_txt), VOTable::_find_attr_value(mparam.__xmlattr, 'value'), (ucd_txt == nil)? nil: Type::UCDType.new(ucd_txt), VOTable::_find_attr_value(mparam.__xmlattr, 'unit'), (mparam.respond_to?(:dESCRIPTION))? _description_from_soap_obj(mparam.dESCRIPTION): nil, (mparam.respond_to?(:vALUES))? _values_from_soap_obj(mparam.vALUES): nil, (mparam.respond_to?(:lINK))? _links_from_soap_obj(mapram.lINK): nil, VOTable::_find_attr_value(mparam.__xmlattr, 'ID'), (precision_txt == nil)? nil: Type::PrecisionType.new(precision_txt.to_i), VOTable::_find_attr_value(mparam.__xmlattr, 'utype'), (width_txt == nil)? nil: Type::PositiveInteger.new(width_txt.to_i), VOTable::_find_attr_value(mparam.__xmlattr, 'ref'), (arraysize_txt == nil)? nil: Type::ArrayDef.new(arraysize_txt) )) end params end |
.from_xml(node) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/voruby/votables/rexml_parser.rb', line 132 def self.from_xml(node) # Attributes id = node.attributes['ID'] if node.attributes['ID'] unit = node.attributes['unit'] if node.attributes['unit'] datatype = Type::DataType.new(node.attributes['datatype']) if node.attributes['datatype'] precision = Type::PrecisionType.new(node.attributes['precision']) if node.attributes['precision'] width = Type::PositiveInteger.new(node.attributes['width'].to_i) if node.attributes['width'] ref = node.attributes['ref'] if node.attributes['ref'] name = node.attributes['name'] if node.attributes['name'] ucd = Type::UCDType.new(node.attributes['ucd']) if node.attributes['ucd'] utype = node.attributes['utype'] if node.attributes['utype'] value = node.attributes['value'] if node.attributes['value'] arraysize = Type::ArrayDef.new(node.attributes['arraysize']) if node.attributes['arraysize'] # Elements description = Meta::Description.from_xml(node.elements.to_a('DESCRIPTION').first) if node.elements['DESCRIPTION'] values = Meta::Values.from_xml(node.elements.to_a('VALUES').first) if node.elements['VALUES'] links = [] node.elements.each('LINK'){ |linkNode| links.push(Meta::Link.from_xml(linkNode)) } return self.new(name, datatype, value, ucd, unit, description, values, links, id, precision, utype, width, ref, arraysize) end |
Instance Method Details
#to_s ⇒ Object
378 379 380 381 382 383 384 385 386 |
# File 'lib/voruby/votables/meta.rb', line 378 def to_s links = @links.collect{|x| x.to_s}.join('|') "{name=#{@name};datatype=#{@datatype};value=#{@value};" + "ucd=#{@ucd};unit=#{@unit};description=#{@description};" + "values=#{@values};links=#{links};" + "id=#{@id};precision=#{@precision};utype=#{@utype};width=#{@width};" + "ref=#{@ref};arraysize=#{@arraysize}}" end |