Class: VORuby::VOTable::V1_0::Param

Inherits:
Base show all
Includes:
Castable
Defined in:
lib/voruby/votable/1.0/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'
)


311
312
313
# File 'lib/voruby/votable/1.0/votable.rb', line 311

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

Class Method Details

.serialization_orderObject



295
296
297
298
299
300
301
# File 'lib/voruby/votable/1.0/votable.rb', line 295

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

Instance Method Details

#arraysizeObject



388
389
390
# File 'lib/voruby/votable/1.0/votable.rb', line 388

def arraysize
  self.node['arraysize']
end

#arraysize=(a) ⇒ Object

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



394
395
396
# File 'lib/voruby/votable/1.0/votable.rb', line 394

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

#datatypeObject



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

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.



340
341
342
# File 'lib/voruby/votable/1.0/votable.rb', line 340

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

#descriptionObject

Retrieve the description (Description).



416
417
418
# File 'lib/voruby/votable/1.0/votable.rb', line 416

def description
  get_element(Description)
end

#description=(d) ⇒ Object

Set the description (Description).



421
422
423
# File 'lib/voruby/votable/1.0/votable.rb', line 421

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

#idObject



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

def id
  self.node['ID']
end

#id=(i) ⇒ Object



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

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

Retrieve the links. Returns a HomogeneousNodeList object.



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

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

#links=(lnks) ⇒ Object

Set the links. Takes an array of Link objects.



443
444
445
# File 'lib/voruby/votable/1.0/votable.rb', line 443

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

#nameObject



371
372
373
# File 'lib/voruby/votable/1.0/votable.rb', line 371

def name
  self.node['name']
end

#name=(n) ⇒ Object



375
376
377
# File 'lib/voruby/votable/1.0/votable.rb', line 375

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

#precisionObject



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

def precision
  self.node['precision']
end

#precision=(p) ⇒ Object

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

param.precision = '1'


351
352
353
# File 'lib/voruby/votable/1.0/votable.rb', line 351

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

#refObject



363
364
365
# File 'lib/voruby/votable/1.0/votable.rb', line 363

def ref
  self.node['ref']
end

#ref=(r) ⇒ Object



367
368
369
# File 'lib/voruby/votable/1.0/votable.rb', line 367

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

#ucdObject



379
380
381
# File 'lib/voruby/votable/1.0/votable.rb', line 379

def ucd
  self.node['ucd']
end

#ucd=(u) ⇒ Object

Set the unified content descriptor or UCD.



384
385
386
# File 'lib/voruby/votable/1.0/votable.rb', line 384

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

#unitObject



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

def unit
  self.node['unit']
end

#unit=(u) ⇒ Object

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



329
330
331
# File 'lib/voruby/votable/1.0/votable.rb', line 329

def unit=(u)
  @node['unit'] = 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.



403
404
405
# File 'lib/voruby/votable/1.0/votable.rb', line 403

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.


411
412
413
# File 'lib/voruby/votable/1.0/votable.rb', line 411

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

#valuesObject

Retrieve the values (Values).



426
427
428
# File 'lib/voruby/votable/1.0/votable.rb', line 426

def values
  get_element(Values)
end

#values=(v) ⇒ Object

Set the values (Values).



431
432
433
# File 'lib/voruby/votable/1.0/votable.rb', line 431

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

#widthObject



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

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

#width=(w) ⇒ Object



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

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