Class: VORuby::VOTables::VOTable::VOTable

Inherits:
Object
  • Object
show all
Defined in:
lib/voruby/votables/votable.rb,
lib/voruby/votables/transforms.rb

Overview

An implementation of a standard VOTable based on the VOTable XML-Schema available at the US-VO. Typically one wouldn’t construct this object directly, but rather use something like VOTable::TreeParsedVOTable to do so from an XML file.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = nil, version = '1.1', description = nil, definitions = nil, coosys = [], params = [], info = [], resources = []) ⇒ VOTable

id:

The VOTable’s ID attribute.

version:

The VOTable version.

description:

The VOTable DESCRIPTION element (type: VOTABLE::META::Description).

definitions:

The VOTable DEFINITIONS element (type: VOTABLE::META::Definitions).

coosys:

The coordinate system (COOSYS) definitions for the the VOTable (type: VOTABLE::META::CooSys).

params:

The PARAM elements for the VOTable (type: VOTABLE::META::Param).

info:

The INFO elements for the VOTable (type: VOTABLE::META::Info).

resources:

The RESOURCE elements for the VOTable (type: VOTABLE::META::Resource).



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/voruby/votables/votable.rb', line 34

def initialize(id=nil, version='1.1', description=nil,
   definitions=nil, coosys=[],
   params=[], info=[], resources=[])
      
  @id = id
  @version = version
      
  Misc::TypeCheck.new(description, Meta::Description).check()
  @description = description
      
  Misc::TypeCheck.new(definitions, Meta::Definitions).check()
  @definitions = definitions
      
  coosys.each{ |sys|
    Misc::TypeCheck.new(sys, Meta::CooSys).check()
  }
  @coosys = coosys
      
  params.each{ |param|
    Misc::TypeCheck.new(param, Meta::Param).check()
  }
  @params = params
      
  info.each{ |inf|
    Misc::TypeCheck.new(inf, Meta::Info).check()
  }
  @info = info
      
  resources.each{ |res|
    Misc::TypeCheck.new(res, Meta::Resource).check()
  }
  @resources = resources
end

Instance Attribute Details

#coosysObject

Returns the value of attribute coosys.



14
15
16
# File 'lib/voruby/votables/votable.rb', line 14

def coosys
  @coosys
end

#definitionsObject

Returns the value of attribute definitions.



14
15
16
# File 'lib/voruby/votables/votable.rb', line 14

def definitions
  @definitions
end

#descriptionObject

Returns the value of attribute description.



14
15
16
# File 'lib/voruby/votables/votable.rb', line 14

def description
  @description
end

#idObject

Returns the value of attribute id.



14
15
16
# File 'lib/voruby/votables/votable.rb', line 14

def id
  @id
end

#infoObject

Returns the value of attribute info.



14
15
16
# File 'lib/voruby/votables/votable.rb', line 14

def info
  @info
end

#paramsObject

Returns the value of attribute params.



14
15
16
# File 'lib/voruby/votables/votable.rb', line 14

def params
  @params
end

#resourcesObject

Returns the value of attribute resources.



14
15
16
# File 'lib/voruby/votables/votable.rb', line 14

def resources
  @resources
end

#versionObject

Returns the value of attribute version.



14
15
16
# File 'lib/voruby/votables/votable.rb', line 14

def version
  @version
end

Class Method Details

._find_attr_value(attributes, name) ⇒ Object



619
620
621
622
623
624
625
# File 'lib/voruby/votables/votable.rb', line 619

def self._find_attr_value(attributes, name)
  attributes.each do |qname, value|
    return value if qname.name == name
  end
      
  return nil
end

.from_soap_obj(mvot) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/voruby/votables/transforms.rb', line 5

def self.from_soap_obj(mvot)
  VOTable.new(
    VOTable::_find_attr_value(mvot.__xmlattr, 'ID'),
    VOTable::_find_attr_value(mvot.__xmlattr, 'version'),
    (mvot.respond_to?(:dESCRIPTION))? Meta::Description.from_soap_obj(mvot.dESCRIPTION): nil,
    (mvot.respond_to?(:dEFINITIONS))? Meta::Definitions.from_soap_obj(mvot.dEFINITIONS): nil,
    (mvot.respond_to?(:cOOSYS))? Meta::CooSys.from_soap_obj(mvot.cOOSYS): [],
    (mvot.respond_to?(:pARAM))? Meta::Param.from_soap_obj(mvot.pARAM): [],
    (mvot.respond_to?(:iNFO))? Meta::Info.from_soap_obj(mvot.iNFO): [],
    (mvot.respond_to?(:rESOURCE))? Meta::Resource.from_soap_obj(mvot.rESOURCE): []
  )
end

Instance Method Details



404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
# File 'lib/voruby/votables/votable.rb', line 404

def create_add_to_cart_link(link_ref, columns)
  access_ref_col = image_access_reference_columns()
  link_ref << '&resource=' + CGI.escape(columns[access_ref_col].value).to_s if access_ref_col
  ra_col = image_ra_columns()
  link_ref << '&rac=' + columns[ra_col].value.to_s if ra_col
  dec_col = image_dec_columns()
  link_ref << '&decc=' + columns[dec_col].value.to_s if dec_col
  filter_col = image_filter_columns()
  link_ref << '&filter=' + columns[filter_col].value.to_s if filter_col
  date_obs_col = image_date_obs_columns()
  link_ref << '&date_obs=' + columns[date_obs_col].value.to_s if date_obs_col
  teles_col = image_telescope_columns()
  link_ref << '&telescop=' + columns[teles_col].value.to_s if teles_col
  survey_col = image_survey_columns()
  link_ref << '&survey=' + columns[survey_col].value.to_s if survey_col
  instrum_col = image_instrument_columns()
  link_ref << '&instrument=' + columns[instrum_col].value.to_s if instrum_col
  sky_col = image_sky_columns()
  link_ref << '&sky=' + columns[sky_col].value.to_s if sky_col
  zerop_col = image_zeropoint_columns()
  link_ref << '&zeropoint=' + columns[zerop_col].value.to_s if zerop_col
  seeing_col = image_seeing_columns()
  link_ref << '&seeing=' + columns[seeing_col].value.to_s if seeing_col
  depth_col = image_depth_columns()
  link_ref << '&depth=' + columns[depth_col].value.to_s if depth_col
  exptime_col = image_exptime_columns()
  link_ref << '&exptime=' + columns[exptime_col].value.to_s if exptime_col
      
  return link_ref
end

#create_body(res, tbl, infer_add_to_cart_ref, add_to_cart_link_value, add_to_cart_link_ref, infer_access_ref, access_ref_link_value, access_ref_col, body_class, row_classes) ⇒ Object

Create body for HTML table

res:

The resource from which to extract the table in question.

tbl:

The table inside the resource from which to extract the rows in question.

infer_add_to_cart_ref:
add_to_cart_link_value:
add_to_cart_link_ref:
infer_access_ref:

Link the access reference URL associated with a row.

access_ref_link_value:

For the access reference column, link this word.

access_ref_col:

A valid SIA VOTable will only ever have one VOX:Image_AccessReference.

body_class:

The class to assign the body of the HTML table.

row_classes:

The class to assign the HTML table body rows.



456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
# File 'lib/voruby/votables/votable.rb', line 456

def create_body(res, tbl,
    infer_add_to_cart_ref, add_to_cart_link_value, add_to_cart_link_ref,
    infer_access_ref, access_ref_link_value, access_ref_col, 
    body_class, row_classes)
      
  tbody = "<tbody class=\"#{body_class}\">\n"
  row_count = 0
  rows(res, tbl).each do |tr|
    tbody << "<tr class=\"#{row_classes[row_count % 2]}\">\n"

    # Specially mark up the first column to link to the image.
    columns = tr.tds()

    if infer_add_to_cart_ref
      archive = add_to_cart_link_ref.slice(add_to_cart_link_ref.index('&archive='), add_to_cart_link_ref.length)
      archive = archive.slice('&archive='.length, archive.length)
      archive = archive.slice(0, archive.index('&')) if archive.index('&')
      link_id = 'add_' + archive.to_s + '_' + row_count.to_s
      url = create_add_to_cart_link(add_to_cart_link_ref, columns)
      js = "new Ajax.Request('#{url}', " +
           "  {method: 'post', " +
           "   onComplete: function(request){Element.hide('#{link_id}');}});"
      tbody << "<td><a id=\"#{link_id}\" href=\"javascript:void(0);\" " +
          "onclick=\"#{js};return false;\"" +
          ">#{add_to_cart_link_value}</a></td>\n"
    end
    if infer_access_ref
      link_ref = columns[access_ref_col].value
      tbody << "<td><a href=\"#{link_ref}\">#{access_ref_link_value}</a></td>\n"
    end

    col_count = 0
    columns.each do |td|
      tbody << "<td>#{td.value}</td>\n" if infer_access_ref and col_count != access_ref_col
      col_count += 1
    end
    tbody << "</tr>\n"
    row_count += 1
  end
  tbody << "</tbody>"
      
  return tbody
end

#create_headers(res, tbl, infer_add_to_cart_ref, add_to_cart_header_value, infer_access_ref, access_ref_header_value, access_ref_col, header_class) ⇒ Object

Create headers for HTML table

res:

The resource from which to extract the table in question.

tbl:

The table inside the resource from which to extract the rows in question.

infer_add_to_cart_ref:
add_to_cart_header_value:
infer_access_ref:

Link the access reference URL associated with a row.

access_ref_header_value:

For the access reference column, place this value in the header.

access_ref_col:

A valid SIA VOTable will only ever have one VOX:Image_AccessReference.

header_class:

The class to assign the header of the HTML table.



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
# File 'lib/voruby/votables/votable.rb', line 364

def create_headers(res, tbl,
    infer_add_to_cart_ref, add_to_cart_header_value,
    infer_access_ref, access_ref_header_value, access_ref_col,
    header_class)
      
  headers = Array.new
  thead = "<thead class=\"#{header_class}\">\n"
      
  thead << "<tr>\n"
  if infer_add_to_cart_ref
    thead << "<th>#{add_to_cart_header_value}</th>\n"
    headers.push('&nbsp')
  end
  if infer_access_ref
    thead << "<th>#{access_ref_header_value}</th>\n"
    headers.push('&nbsp')
  end
  col_count = 0
  fields(res, tbl).each do |field|
    if infer_access_ref and col_count == access_ref_col
      headers[1] = field.ucd.value
    else
      thead << "<th>#{field.name}</th>\n"
      headers.push(field.ucd.value)
    end
    col_count += 1
  end
  thead << "  </tr>\n"
      
  thead << "<tr>\n"
  headers.each do |h|
    thead << "<th>#{h}</th>\n"
  end
  thead << "</tr>\n"
      
  thead << "</thead>"
      
  return thead
end

#create_message_table(table_class, header_class, body_class, row_classes, title, message) ⇒ Object



597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
# File 'lib/voruby/votables/votable.rb', line 597

def create_message_table(table_class, header_class, body_class,
    row_classes, title, message)
  table = "<table class=\"#{table_class}\" width=\"100%\">\n"
      
  table << " <thead class=\"#{header_class}\">\n"
  table << "  <tr>\n"
  table << "    <th>#{title}</th>\n"
  table << "  </tr>\n"
  table << " </thead>\n"
      
  table << " <tbody class=\"#{body_class}\">\n"
  table << "  <tr class=\"#{row_classes[0]}\">\n"
  table << "   <td align=\"center\"><label>VOTable message: #{message}" +
      "</label></td>\n"
  table << "  </tr>\n"
  table << " </tbody>\n"
      
  table << "</table>"
      
  return table
end

#create_table(id, show_border, table_class, thead, tbody) ⇒ Object

Create table for HTML VOTable

id:

The ID to assign to the HTML table as a whole.

show_border:

The boolean value to show HTML table border.

table_class:

The class to assign the HTML table as a whole.

thead:

The class to assign the HTML table thead.

tbody:

The class to assign the HTML table tbody.



511
512
513
514
515
516
517
518
# File 'lib/voruby/votables/votable.rb', line 511

def create_table(id, show_border, table_class, thead, tbody)
  table = "<table class=\"#{table_class}\""
  table << " id=\"#{id}\"" if id
  table << " border=\"1\"" if show_border
  table << " width=\"100%\">\n"
  table << "#{thead}\n#{tbody}\n</table>"
  return table
end

#date_of_observation_fields(res = 0, tbl = 0) ⇒ Object

Find the date of observation fields in a votable using UCDs. This should work for both version 1 and 1+ UCDs, including experimental (e.g. VOX) ones. Returns a hash of the positions of the fields and their corresponding VOTABLE::META::Field object.

res:

The resource from which to extract the table in question.

tbl:

The resource from which to extract the table in question.



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/voruby/votables/votable.rb', line 184

def date_of_observation_fields(res=0, tbl=0)
  date_obs = {}
      
  field_count = 0
  fields(res, tbl).each do |field|
    if field.ucd() != nil
      ucd = field.ucd()
      dt = field.datatype()
      # Determine if the UCD is of interest.
      if ucd.value() == 'VOX:Image_MJDateObs' or
        (dt.value() == 'double' and (ucd.value() == 'TIME_DATE' or ucd.value() == 'time.epoch'))
        date_obs[field_count] = field
      end
    end
    field_count = field_count + 1
  end
  return date_obs
end

#fields(res = 0, tbl = 0) ⇒ Object

A convenience method for accessing the fields of a votable, rather than having to iterate through each resource and table manually. Returns a list of VOTABLE::META::Field objects.

res:

The resource from which to extract the table in question.

tbl:

The resource from which to extract the table in question.



89
90
91
# File 'lib/voruby/votables/votable.rb', line 89

def fields(res=0, tbl=0)
  @resources[res].tables()[tbl].fields() if @resources[res]
end

#find_columns(ucd, res = 0, tbl = 0) ⇒ Object

Find the column number(s) associated with a UCD. Returns a list of column positions.

res:

The resource from which to extract the table in question.

tbl:

The resource from which to extract the table in question.



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/voruby/votables/votable.rb', line 232

def find_columns(ucd, res=0, tbl=0)
  columns = []
      
  col_count = 0
  fields = fields(res, tbl)
  if fields
    fields.each do |field|
      if field.ucd() != nil
        tbl_ucd = field.ucd()
        columns.push(col_count) if tbl_ucd.value() == ucd
      end  
      col_count += 1
    end
  end
  return columns
end

#image_access_reference_columnsObject

Find the column number(s) associated with the VOX:imageAccessReference UCD. Returns a list of column positions.



252
253
254
255
256
257
258
259
260
261
# File 'lib/voruby/votables/votable.rb', line 252

def image_access_reference_columns
  # The following is correct 
  # find_columns('VOX:Image_AccessReference').first
  # The following is cause XMM ticks me off (not valid SIAP).
  if find_columns('VOX:Image_AccessReference').first != nil 
    find_columns('VOX:Image_AccessReference').first
  else
    find_columns('DATA_LINK').first
  end
end

#image_date_obs_columnsObject



287
288
289
290
291
# File 'lib/voruby/votables/votable.rb', line 287

def image_date_obs_columns
  if find_columns('time.obs.start').first != nil
    find_columns('time.obs.start').first
  end
end

#image_dec_columnsObject



271
272
273
274
275
276
277
# File 'lib/voruby/votables/votable.rb', line 271

def image_dec_columns
  if find_columns('POS_EQ_DEC_MAIN').first != nil
    find_columns('POS_EQ_DEC_MAIN').first
  elsif find_columns('pos.eq.dec;meta.main').first != nil
    find_columns('pos.eq.dec;meta.main').first
  end
end

#image_depth_columnsObject



335
336
337
338
339
# File 'lib/voruby/votables/votable.rb', line 335

def image_depth_columns
  #if find_columns('').first != nil
  #  find_columns('').first
  #end
end

#image_exptime_columnsObject



341
342
343
344
345
# File 'lib/voruby/votables/votable.rb', line 341

def image_exptime_columns
  if find_columns('time.expo').first != nil
    find_columns('time.expo').first
  end
end

#image_filter_columnsObject



279
280
281
282
283
284
285
# File 'lib/voruby/votables/votable.rb', line 279

def image_filter_columns
  if find_columns('VOX:BandPass_ID').first != nil
    find_columns('VOX:BandPass_ID').first
  elsif find_columns('instr.filter').first != nil
    find_columns('instr.filter').first
  end
end

#image_instrument_columnsObject



307
308
309
310
311
312
313
314
315
# File 'lib/voruby/votables/votable.rb', line 307

def image_instrument_columns
  if find_columns('VOX:INST_ID').first != nil
    find_columns('VOX:INST_ID').first
  elsif find_columns('INST_ID').first != nil
    find_columns('INST_ID').first
  elsif find_columns('instr').first != nil
    find_columns('instr').first
  end
end

#image_ra_columnsObject



263
264
265
266
267
268
269
# File 'lib/voruby/votables/votable.rb', line 263

def image_ra_columns
  if find_columns('POS_EQ_RA_MAIN').first != nil
    find_columns('POS_EQ_RA_MAIN').first
  elsif find_columns('pos.eq.ra;meta.main').first != nil
    find_columns('pos.eq.ra;meta.main').first
  end
end

#image_seeing_columnsObject



329
330
331
332
333
# File 'lib/voruby/votables/votable.rb', line 329

def image_seeing_columns
  if find_columns('instr.obsty.seeing').first != nil
    find_columns('instr.obsty.seeing').first
  end
end

#image_sky_columnsObject



317
318
319
320
321
# File 'lib/voruby/votables/votable.rb', line 317

def image_sky_columns
  if find_columns('instr.skyLevel').first != nil
    find_columns('instr.skyLevel').first
  end
end

#image_survey_columnsObject



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

def image_survey_columns
  if find_columns('VOX:Image_Title').first != nil
    find_columns('VOX:Image_Title').first
  elsif find_columns('ID_SURVEY').first != nil
    find_columns('ID_SURVEY').first
  end
end

#image_telescope_columnsObject



293
294
295
296
297
# File 'lib/voruby/votables/votable.rb', line 293

def image_telescope_columns
  if find_columns('instr.tel').first != nil
    find_columns('instr.tel').first
  end
end

#image_zeropoint_columnsObject



323
324
325
326
327
# File 'lib/voruby/votables/votable.rb', line 323

def image_zeropoint_columns
  if find_columns('arith.zp;phot').first != nil
    find_columns('arith.zp;phot').first
  end
end

#main_positional_fields(res = 0, tbl = 0) ⇒ Object

Find the main positional right ascension and declination fields in a votable using UCDs. This should work for both version 1 and 1+ UCDs. Returns a hash with the keys “ra” and “dec”.

res:

The resource from which to extract the table in question.

tbl:

The resource from which to extract the table in question.



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/voruby/votables/votable.rb', line 131

def main_positional_fields(res=0, tbl=0)
  main_pos = {}
      
  field_count = 0
  fields(res, tbl).each do |field|
    if field.ucd() != nil
      ucd = field.ucd()
      # Determine if the UCD is of intereset.
      if ucd.value() == 'POS_EQ_RA_MAIN' or ucd.value() == 'pos.eq.ra;meta.main' # RA
        main_pos["ra"] = [field_count, field]
      elsif ucd.value() == 'POS_EQ_DEC_MAIN' or ucd.value() == 'pos.eq.dec;meta.main' # Dec
        main_pos["dec"] = [field_count, field]
      end
    end
    field_count = field_count + 1
  end
  return main_pos
end

#number_of_fields(res = 0, tbl = 0) ⇒ Object

A convenience method for determining the number of columns in a votable.

res:

The resource from which to extract the table in question.

tbl:

The resource from which to extract the table in question.



99
100
101
# File 'lib/voruby/votables/votable.rb', line 99

def number_of_fields(res=0, tbl=0)
  return fields(res, tbl).length() || []
end

#number_of_rows(res = 0, tbl = 0) ⇒ Object

A convenience method for determining the number of data rows in a votable.

res:

The resource from which to extract the table in question.

tbl:

The resource from which to extract the table in question.



119
120
121
# File 'lib/voruby/votables/votable.rb', line 119

def number_of_rows(res=0, tbl=0)
  return rows(res, tbl).length()
end

#positional_fields(res = 0, tbl = 0) ⇒ Object

Find positional fields in a votable using UCDs. This should work for both version 1 and 1+ UCDs. Returns a hash of the positions of the fields and their corresponding VOTABLE::META::Field object.

res:

The resource from which to extract the table in question.

tbl:

The resource from which to extract the table in question.



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/voruby/votables/votable.rb', line 158

def positional_fields(res=0, tbl=0)
  pos = {}
      
  field_count = 0
  fields(res, tbl).each do |field|
    if field.ucd() != nil
      ucd = field.ucd()
      # Determine if the UCD is of interest
      if ucd.value() =~ /^POS.*/ or ucd.value() =~ /^pos\..*/
        pos[field_count] = field
      end
    end
    field_count = field_count + 1
  end
  return pos
end

#rows(res = 0, tbl = 0) ⇒ Object

A convenience method for accessing the row data of a votable. Returns a list of VOTABLE::DATA::TR objects.

res:

The resource from which to extract the table in question.

tbl:

The resource from which to extract the table in question.



109
110
111
# File 'lib/voruby/votables/votable.rb', line 109

def rows(res=0, tbl=0)
  @resources[res].tables()[tbl].data().format().trs()
end

#time_fields(res = 0, tbl = 0) ⇒ Object

Find time fields in a votable using UCDs. This should work for both version 1 and 1+ UCDs, including experimental (e.g. VOX) ones. Returns a hash of the positions of the fields and their corresponding VOTABLE::META::Field object.

res:

The resource from which to extract the table in question.

tbl:

The resource from which to extract the table in question.



211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/voruby/votables/votable.rb', line 211

def time_fields(res=0, tbl=0)
  times = {}
  field_count = 0
  fields(res, tbl).each do |field|
    if field.ucd() != nil
      ucd = field.ucd()
      if ucd.value() =~ /^TIME.*/ or ucd.value() =~ /time\..*/ or ucd.value() == 'VOX:Image_MJDateObs'
        times[field_count] = field
      end
    end
    field_count = field_count + 1
  end
  return times
end

#to_html(id = nil, add_to_cart_link_ref = nil, res = 0, tbl = 0, infer_add_to_cart_ref = true, add_to_cart_header_value = 'Add to Cart', add_to_cart_link_value = 'Add', infer_access_ref = true, access_ref_header_value = 'URL', access_ref_link_value = 'Retrieve', show_border = false, table_class = 'votable', header_class = 'header', body_class = 'body', row_classes = ['row1', 'row2']) ⇒ Object

Convert the specified table in the specified resource into an HTML table.

id:

The ID to assign to the HTML table as a whole.

add_to_cart_link_ref:
res:

The resource from which to extract the table in question.

tbl:

The table inside the resource from which to extract the rows in question.

infer_add_to_cart_ref:
add_to_cart_header_value:
add_to_cart_link_value:
infer_access_ref:

Link the access reference URL associated with a row.

access_ref_header_value:

For the access reference column, place this value in the header.

access_ref_link_value:

For the access reference column, link this word.

show_border:

The boolean value to show HTML table border

table_class:

The class to assign the HTML table as a whole.

header_class:

The class to assign the header of the HTML table.

body_class:

The class to assign the body of the HTML table.

row_classes:

The class to assign the HTML table body rows.



552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
# File 'lib/voruby/votables/votable.rb', line 552

def to_html(id=nil, add_to_cart_link_ref=nil, res=0, tbl=0,
    infer_add_to_cart_ref=true,
    add_to_cart_header_value='Add to Cart',
    add_to_cart_link_value='Add',
    infer_access_ref=true,
    access_ref_header_value='URL',
    access_ref_link_value='Retrieve',
    show_border=false,
    table_class='votable',
    header_class='header',
    body_class='body',
    row_classes=['row1', 'row2'])
  begin
    # A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
    access_ref_col = image_access_reference_columns()

    if access_ref_col
      # Create headers
      thead = create_headers(res, tbl,
        infer_add_to_cart_ref, add_to_cart_header_value,
        infer_access_ref, access_ref_header_value, access_ref_col,
        header_class)
  
      # Create body
      tbody = create_body(res, tbl,
        infer_add_to_cart_ref, add_to_cart_link_value, add_to_cart_link_ref,
        infer_access_ref, access_ref_link_value, access_ref_col,
        body_class, row_classes)
  
      return create_table(id, show_border, table_class, thead, tbody)
    else
      title = 'No Data'
      message = 'VOTable not contains data.'
      return create_message_table(table_class, header_class,
        body_class, row_classes, title, message)
    end

    rescue Exception => e
      title = 'Error'
      message = e.backtrace#@resources[0].info[0].text().to_s()
      table = create_message_table(table_class, header_class,
        body_class, row_classes, title, message)
  end
end

#to_sObject

Get the compact string representation of the VOTable.



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/voruby/votables/votable.rb', line 69

def to_s
  coosys = @coosys.each{|x| x.to_s}.join('|')
  params = @params.each{|x| x.to_s}.join('|')
  info = @info.each{|x| x.to_s}.join('|')
  resources = @resources.each{|x| x.to_s}.join('|') 
      
  return "{id=#{@id};version=#{@version};" +
    "description=#{@description};definitions=#{@definitions};" +
    "coosys=#{coosys};params=#{params};info=#{info};" +
    "resources=#{resources}}"
end