Class: VORuby::VOTable::V1_0::Field

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

Overview

The description of an actual table column.

Constant Summary collapse

ELEMENT_NAME =
'FIELD'

Instance Attribute Summary

Attributes inherited from XML::Object::Base

#node

Class Method Summary collapse

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

Create a new table column description.

field = Field.new(
  :name => 'RA',
  :id => 'col1',
  :ucd => 'pos.eq.ra;meta.main',
  :ref => 'J2000',
  :datatype => 'float',
  :width => 6,
  :precision => '2',
  :unit => 'deg'
)


1010
1011
1012
# File 'lib/voruby/votable/1.0/votable.rb', line 1010

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

Class Method Details

.serialization_orderObject



991
992
993
994
995
996
997
# File 'lib/voruby/votable/1.0/votable.rb', line 991

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

Instance Method Details

#arraysizeObject



1090
1091
1092
# File 'lib/voruby/votable/1.0/votable.rb', line 1090

def arraysize
  self.node['arraysize']
end

#arraysize=(a) ⇒ Object

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



1096
1097
1098
# File 'lib/voruby/votable/1.0/votable.rb', line 1096

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

#datatypeObject



1032
1033
1034
# File 'lib/voruby/votable/1.0/votable.rb', line 1032

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.



1039
1040
1041
# File 'lib/voruby/votable/1.0/votable.rb', line 1039

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

#descriptionObject

Retrieve the description (Description).



1110
1111
1112
# File 'lib/voruby/votable/1.0/votable.rb', line 1110

def description
  get_element(Description)
end

#description=(d) ⇒ Object

Set the description (Description).



1115
1116
1117
# File 'lib/voruby/votable/1.0/votable.rb', line 1115

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

#idObject



1014
1015
1016
# File 'lib/voruby/votable/1.0/votable.rb', line 1014

def id
  self.node['ID']
end

#id=(i) ⇒ Object



1018
1019
1020
# File 'lib/voruby/votable/1.0/votable.rb', line 1018

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

Retrieve the links. Returns a HomogeneousNodeList object.



1131
1132
1133
# File 'lib/voruby/votable/1.0/votable.rb', line 1131

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

#links=(lnks) ⇒ Object

Set the links. Takes an array of Link objects.



1137
1138
1139
# File 'lib/voruby/votable/1.0/votable.rb', line 1137

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

#nameObject



1073
1074
1075
# File 'lib/voruby/votable/1.0/votable.rb', line 1073

def name
  self.node['name']
end

#name=(n) ⇒ Object



1077
1078
1079
# File 'lib/voruby/votable/1.0/votable.rb', line 1077

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

#precisionObject



1043
1044
1045
# File 'lib/voruby/votable/1.0/votable.rb', line 1043

def precision
  self.node['precision']
end

#precision=(p) ⇒ Object

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

param.precision = '1'


1050
1051
1052
# File 'lib/voruby/votable/1.0/votable.rb', line 1050

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

#refObject



1065
1066
1067
# File 'lib/voruby/votable/1.0/votable.rb', line 1065

def ref
  self.node['ref']
end

#ref=(r) ⇒ Object



1069
1070
1071
# File 'lib/voruby/votable/1.0/votable.rb', line 1069

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

#to_htmlObject

Convert a field to HTML.



1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
# File 'lib/voruby/votable/1.0/votable.rb', line 1142

def to_html
  builder = Builder::XmlMarkup.new(:indent => 2, :margin => 6)
  
  field_opts = {:class => 'field'}
  field_opts[:id] = self.id if self.id
  
  builder.div(field_opts) { |field|
    field.div(self.name, :class => 'name')
    field.div(self.ucd, :class => 'ucd') if self.ucd
    field.div(self.unit, :class => 'unit') if self.unit
    field.span(self.datatype, :class => 'datatype') if self.datatype
    field.span(self.arraysize, :class => 'arraysize') if self.arraysize
  }
end

#typeObject



1100
1101
1102
# File 'lib/voruby/votable/1.0/votable.rb', line 1100

def type
  self.node['type']
end

#type=(t) ⇒ Object

Set the type. May be one of: hidden, no_query or trigger.



1105
1106
1107
# File 'lib/voruby/votable/1.0/votable.rb', line 1105

def type=(t)
  @node['type'] = t.to_s
end

#ucdObject



1081
1082
1083
# File 'lib/voruby/votable/1.0/votable.rb', line 1081

def ucd
  self.node['ucd']
end

#ucd=(u) ⇒ Object

Set the unified content descriptor or UCD.



1086
1087
1088
# File 'lib/voruby/votable/1.0/votable.rb', line 1086

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

#unitObject



1022
1023
1024
# File 'lib/voruby/votable/1.0/votable.rb', line 1022

def unit
  self.node['unit']
end

#unit=(u) ⇒ Object

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



1028
1029
1030
# File 'lib/voruby/votable/1.0/votable.rb', line 1028

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

#valuesObject

Retrieve the values (Values).



1120
1121
1122
# File 'lib/voruby/votable/1.0/votable.rb', line 1120

def values
  HomogeneousNodeList.new(self.node, xpath_for(Values), Values)
end

#values=(vals) ⇒ Object

Set the values (Values).



1125
1126
1127
# File 'lib/voruby/votable/1.0/votable.rb', line 1125

def values=(vals)
  self.values.replace(vals)
end

#widthObject



1054
1055
1056
# File 'lib/voruby/votable/1.0/votable.rb', line 1054

def width
  self.node['width'] ? self.node['width'].to_i : nil
end

#width=(w) ⇒ Object

Set the width. Should be an integer.

param.width = 2


1061
1062
1063
# File 'lib/voruby/votable/1.0/votable.rb', line 1061

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