Class: VORuby::VOTable::V1_1::Field
- Inherits:
-
Base
- Object
- XML::Object::Base
- Base
- VORuby::VOTable::V1_1::Field
- Defined in:
- lib/voruby/votable/1.1/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
Class Method Summary collapse
Instance Method Summary collapse
- #arraysize ⇒ Object
-
#arraysize=(a) ⇒ Object
Set the arraysize (if applicable).
- #datatype ⇒ Object
-
#datatype=(d) ⇒ Object
Set the datatype.
-
#description ⇒ Object
Retrieve the description (Description).
-
#description=(d) ⇒ Object
Set the description (Description).
- #id ⇒ Object
- #id=(i) ⇒ Object
-
#initialize(defn = nil) ⇒ Field
constructor
Create a new table column description.
-
#links ⇒ Object
Retrieve the links.
-
#links=(lnks) ⇒ Object
Set the links.
- #name ⇒ Object
- #name=(n) ⇒ Object
- #precision ⇒ Object
-
#precision=(p) ⇒ Object
Set the precision of the value.
- #ref ⇒ Object
- #ref=(r) ⇒ Object
-
#to_html ⇒ Object
Convert a field to HTML.
-
#type ⇒ Object
DEPRECATED.
-
#type=(t) ⇒ Object
May be on of: hidden, no_query, trigger or location.
- #ucd ⇒ Object
-
#ucd=(u) ⇒ Object
Set the unified content descriptor or UCD.
- #unit ⇒ Object
-
#unit=(u) ⇒ Object
Set the unit.
- #utype ⇒ Object
-
#utype=(u) ⇒ Object
Set the utype (i.e. the role of the column in the context of an external data model).
-
#values ⇒ Object
Retrieve the values (Values).
-
#values=(vals) ⇒ Object
Set the values (Values).
- #width ⇒ Object
-
#width=(w) ⇒ Object
Set the width.
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'
)
1091 1092 1093 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1091 def initialize(defn=nil) super(defn) end |
Class Method Details
.serialization_order ⇒ Object
1072 1073 1074 1075 1076 1077 1078 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1072 def self.serialization_order [ :description, :values, :links, :id, :unit, :datatype, :precision, :width, :ref, :name, :ucd, :utype, :arraysize, :type ] end |
Instance Method Details
#arraysize ⇒ Object
1180 1181 1182 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1180 def arraysize self.node['arraysize'] end |
#arraysize=(a) ⇒ Object
Set the arraysize (if applicable). i.e. *, 8x2
1186 1187 1188 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1186 def arraysize=(a) @node['arraysize'] = a.to_s end |
#datatype ⇒ Object
1113 1114 1115 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1113 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.
1120 1121 1122 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1120 def datatype=(d) @node['datatype'] = d.to_s end |
#description ⇒ Object
Retrieve the description (Description).
1202 1203 1204 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1202 def description get_element(Description) end |
#description=(d) ⇒ Object
Set the description (Description).
1207 1208 1209 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1207 def description=(d) set_element(Description, d) end |
#id ⇒ Object
1095 1096 1097 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1095 def id self.node['ID'] end |
#id=(i) ⇒ Object
1099 1100 1101 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1099 def id=(i) @node['ID'] = i.to_s end |
#links ⇒ Object
Retrieve the links. Returns a HomogeneousNodeList object.
1223 1224 1225 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1223 def links HomogeneousNodeList.new(self.node, xpath_for(Link), Link) end |
#links=(lnks) ⇒ Object
Set the links. Takes an array of Link objects.
1229 1230 1231 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1229 def links=(lnks) self.links.replace(lnks) end |
#name ⇒ Object
1154 1155 1156 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1154 def name self.node['name'] end |
#name=(n) ⇒ Object
1158 1159 1160 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1158 def name=(n) @node['name'] = n.to_s end |
#precision ⇒ Object
1124 1125 1126 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1124 def precision self.node['precision'] end |
#precision=(p) ⇒ Object
Set the precision of the value. Should match [EF]?[0-9]*
param.precision = '1'
1131 1132 1133 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1131 def precision=(p) @node['precision'] = p.to_s end |
#ref ⇒ Object
1146 1147 1148 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1146 def ref self.node['ref'] end |
#ref=(r) ⇒ Object
1150 1151 1152 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1150 def ref=(r) @node['ref'] = r.to_s end |
#to_html ⇒ Object
Convert a field to HTML.
1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1234 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.utype, :class => 'utype') if self.utype 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 |
#type ⇒ Object
DEPRECATED
1191 1192 1193 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1191 def type self.node['type'] end |
#type=(t) ⇒ Object
May be on of: hidden, no_query, trigger or location. DEPRECATED
1197 1198 1199 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1197 def type=(t) @node['type'] = t.to_s end |
#ucd ⇒ Object
1162 1163 1164 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1162 def ucd self.node['ucd'] end |
#ucd=(u) ⇒ Object
Set the unified content descriptor or UCD.
1167 1168 1169 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1167 def ucd=(u) @node['ucd'] = u.to_s end |
#unit ⇒ Object
1103 1104 1105 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1103 def unit self.node['unit'] end |
#unit=(u) ⇒ Object
Set the unit. Units should be of the form outlined by Vizier.
1109 1110 1111 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1109 def unit=(u) @node['unit'] = u.to_s end |
#utype ⇒ Object
1171 1172 1173 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1171 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).
1176 1177 1178 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1176 def utype=(u) @node['utype'] = u.to_s end |
#values ⇒ Object
Retrieve the values (Values).
1212 1213 1214 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1212 def values HomogeneousNodeList.new(self.node, xpath_for(Values), Values) end |
#values=(vals) ⇒ Object
Set the values (Values).
1217 1218 1219 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1217 def values=(vals) self.values.replace(vals) end |
#width ⇒ Object
1135 1136 1137 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1135 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
1142 1143 1144 |
# File 'lib/voruby/votable/1.1/votable.rb', line 1142 def width=(w) @node['width'] = w.to_s end |