Class: VORuby::VOTable::V1_1::Param

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

Overview

A global value associated with (usually) a table.

Constant Summary collapse

ELEMENT_NAME =
'PARAM'

Instance Attribute Summary

Attributes inherited from XML::Object::Base

#node

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Castable

#as_obj, #as_string, #cast, #convert_to_s

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) ⇒ Param

Create a new parameter.

param = Param.new(
  :name => 'Telescope',
  :datatype => 'float',
  :ucd => 'phys.size;instr.tel',
  :unit => 'm',
  :value => '3.6'
)


315
316
317
# File 'lib/voruby/votable/1.1/votable.rb', line 315

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

Class Method Details

.serialization_orderObject



299
300
301
302
303
304
305
# File 'lib/voruby/votable/1.1/votable.rb', line 299

def self.serialization_order
  [
    :description, :values, :links,
    :id, :unit, :datatype, :arraysize, :precision, :width, :ref, :name,
    :ucd, :utype, :value
  ]
end

Instance Method Details

#arraysizeObject



404
405
406
# File 'lib/voruby/votable/1.1/votable.rb', line 404

def arraysize
  self.node['arraysize']
end

#arraysize=(a) ⇒ Object

Set the arraysize (if applicable). i.e. *, 8x2



410
411
412
# File 'lib/voruby/votable/1.1/votable.rb', line 410

def arraysize=(a)
  @node['arraysize'] = a.to_s
end

#datatypeObject



337
338
339
# File 'lib/voruby/votable/1.1/votable.rb', line 337

def datatype
  self.node['datatype']
end

#datatype=(d) ⇒ Object

Set the datatype. Should be one of: boolean, bit, unsignedByte, short, int, long, char, unicodeChar, float, double, floatComplex, doubleComplex.



344
345
346
# File 'lib/voruby/votable/1.1/votable.rb', line 344

def datatype=(d)
  @node['datatype'] = d.to_s
end

#descriptionObject

Retrieve the description (Description).



432
433
434
# File 'lib/voruby/votable/1.1/votable.rb', line 432

def description
  get_element(Description)
end

#description=(d) ⇒ Object

Set the description (Description).



437
438
439
# File 'lib/voruby/votable/1.1/votable.rb', line 437

def description=(d)
  set_element(Description, d)
end

#idObject



319
320
321
# File 'lib/voruby/votable/1.1/votable.rb', line 319

def id
  self.node['ID']
end

#id=(i) ⇒ Object



323
324
325
# File 'lib/voruby/votable/1.1/votable.rb', line 323

def id=(i)
  @node['ID'] = i.to_s
end

Retrieve the links. Returns a HomogeneousNodeList object.



453
454
455
# File 'lib/voruby/votable/1.1/votable.rb', line 453

def links
  HomogeneousNodeList.new(self.node, xpath_for(Link), Link)
end

#links=(lnks) ⇒ Object

Set the links. Takes an array of Link objects.



459
460
461
# File 'lib/voruby/votable/1.1/votable.rb', line 459

def links=(lnks)
  self.links.replace(lnks)
end

#nameObject



378
379
380
# File 'lib/voruby/votable/1.1/votable.rb', line 378

def name
  self.node['name']
end

#name=(n) ⇒ Object



382
383
384
# File 'lib/voruby/votable/1.1/votable.rb', line 382

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

#precisionObject



348
349
350
# File 'lib/voruby/votable/1.1/votable.rb', line 348

def precision
  self.node['precision']
end

#precision=(p) ⇒ Object

Set the precision of the value. Should match [EF]?[0-9]*

param.precision = '1'


355
356
357
# File 'lib/voruby/votable/1.1/votable.rb', line 355

def precision=(p)
  @node['precision'] = p.to_s
end

#refObject



370
371
372
# File 'lib/voruby/votable/1.1/votable.rb', line 370

def ref
  self.node['ref']
end

#ref=(r) ⇒ Object



374
375
376
# File 'lib/voruby/votable/1.1/votable.rb', line 374

def ref=(r)
  @node['ref'] = r.to_s
end

#ucdObject



386
387
388
# File 'lib/voruby/votable/1.1/votable.rb', line 386

def ucd
  self.node['ucd']
end

#ucd=(u) ⇒ Object

Set the unified content descriptor or UCD.



391
392
393
# File 'lib/voruby/votable/1.1/votable.rb', line 391

def ucd=(u)
  @node['ucd'] = u.to_s
end

#unitObject



327
328
329
# File 'lib/voruby/votable/1.1/votable.rb', line 327

def unit
  self.node['unit']
end

#unit=(u) ⇒ Object

Set the unit. Units should be of the form outlined by Vizier.



333
334
335
# File 'lib/voruby/votable/1.1/votable.rb', line 333

def unit=(u)
  @node['unit'] = u.to_s
end

#utypeObject



395
396
397
# File 'lib/voruby/votable/1.1/votable.rb', line 395

def utype
  self.node['utype']
end

#utype=(u) ⇒ Object

Set the utype (i.e. the role of the column in the context of an external data model).



400
401
402
# File 'lib/voruby/votable/1.1/votable.rb', line 400

def utype=(u)
  @node['utype'] = u.to_s
end

#value(cast = false) ⇒ Object

Retrieve the value of the parameter. If cast is false (default), the value is returned as a simple string. However, if cast is true, the datatype and arraysize are used to determine a suitable object (or list of objects) to return. See Castable#as_obj for more details.



419
420
421
# File 'lib/voruby/votable/1.1/votable.rb', line 419

def value(cast=false)
  cast ? as_obj(self.value, self.datatype, self.arraysize) : self.node['value']
end

#value=(v) ⇒ Object

Set the value of the parameter. An attempt is made to convert native ruby types using the datatype and arraysize parameters.

param.value = Complex.new(1.1, 2.2)  # etc.


427
428
429
# File 'lib/voruby/votable/1.1/votable.rb', line 427

def value=(v)
  @node['value'] = v.is_a?(String) ? v : as_string(v, self.datatype, self.arraysize)
end

#valuesObject

Retrieve the values (Values).



442
443
444
# File 'lib/voruby/votable/1.1/votable.rb', line 442

def values
  get_element(Values)
end

#values=(v) ⇒ Object

Set the values (Values).



447
448
449
# File 'lib/voruby/votable/1.1/votable.rb', line 447

def values=(v)
  set_element(Values, v)
end

#widthObject



359
360
361
# File 'lib/voruby/votable/1.1/votable.rb', line 359

def width
  self.node['width'].to_i
end

#width=(w) ⇒ Object

Set the width. Should be an integer.

param.width = 2


366
367
368
# File 'lib/voruby/votable/1.1/votable.rb', line 366

def width=(w)
  @node['width'] = w.to_s
end