Class: VORuby::VOTables::VOTable::INTVOTable
- Inherits:
-
VORuby::VOTables::VOTable
- Object
- VORuby::VOTables::VOTable
- VORuby::VOTables::VOTable::INTVOTable
- Defined in:
- lib/voruby/votables/int.rb
Instance Method Summary collapse
-
#create_body(access_ref_index, options) ⇒ Object
Create body for HTML table [access_ref_index:] A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
-
#create_headers(access_ref_index, options) ⇒ Object
Create the headers for HTML table [access_ref_index:] A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
-
#create_item_cart_params(cart_params, columns) ⇒ Object
Creates the cart parameters [cart_params:].
-
#find_field_in_conf_file(key) ⇒ Object
Find a field in INT configuration file given a key.
-
#image_access_reference_columns ⇒ Object
Find the column number(s) associated with the VOX:imageAccessReference UCD.
- #image_date_obs_columns ⇒ Object
- #image_dec_columns ⇒ Object
- #image_depth_columns ⇒ Object
- #image_exptime_columns ⇒ Object
- #image_filter_columns ⇒ Object
- #image_instrument_columns ⇒ Object
- #image_ra_columns ⇒ Object
- #image_seeing_columns ⇒ Object
- #image_sky_columns ⇒ Object
- #image_survey_columns ⇒ Object
- #image_telescope_columns ⇒ Object
- #image_zeropoint_columns ⇒ Object
-
#initialize(votable) ⇒ INTVOTable
constructor
Our object’s contructor [votable:] The VOTable object.
-
#to_html(options = {}) ⇒ Object
Convert the specified table in the specified resource into an HTML table.
Constructor Details
#initialize(votable) ⇒ INTVOTable
Our object’s contructor
- votable:
-
The VOTable object
16 17 18 19 20 |
# File 'lib/voruby/votables/int.rb', line 16 def initialize(votable) super(votable.id, votable.version, votable.description, votable.definitions, votable.coosys, votable.params, votable.info, votable.resources) end |
Instance Method Details
#create_body(access_ref_index, options) ⇒ Object
Create body for HTML table
- access_ref_index:
-
A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
- options:
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/voruby/votables/int.rb', line 241 def create_body(access_ref_index, ) tbody = "<tbody class=\"#{[:body_class]}\" align=\"center\">\n" row_count = 0 rows_data = rows([:res], [:tbl]) if rows_data rows_data.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] and access_ref_index tbody << "<td><input type=\"checkbox\" " + "id=\"checkbox_add_#{[:cart_params][:archive]}_#{row_count.to_s}\" " + "value=\"#{create_item_cart_params([:cart_params], columns)}\"/></td>\n" end if [:infer_access_ref] and access_ref_index tbody << "<td><a href=\"#{columns[access_ref_index].value}\">#{[:access_ref_link_label]}</a></td>\n" end col_count = 0 #ra_index = image_ra_columns() #dec_index = image_dec_columns() columns.each do |td| if col_count != access_ref_index #if ra_index and col_count == ra_index # tbody << "<td>#{convert_ra_to_degrees(td.value)}</td>\n" #elsif dec_index and col_count == dec_index # tbody << "<td>#{convert_dec_to_degrees(td.value)}</td>\n" #else tbody << "<td>#{td.value}</td>\n" #end end col_count += 1 end tbody << "</tr>\n" row_count += 1 end end tbody << "</tbody>" return tbody end |
#create_headers(access_ref_index, options) ⇒ Object
Create the headers for HTML table
- access_ref_index:
-
A valid SIA VOTable will only ever have one VOX:Image_AccessReference.
- options:
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/voruby/votables/int.rb', line 156 def create_headers(access_ref_index, ) thead, thead_2row = create_header_cart_links() if [:infer_access_ref] and access_ref_index thead << "<th>#{[:access_ref_header_label]}</th>\n" thead_2row.push(' ') end col_count = 0 fields([:res], [:tbl]).each do |field| field_archive = find_field_in_conf_file(field.ucd.value()) field_ucd = field_archive['ucd'] if [:infer_access_ref] and col_count == access_ref_index thead_2row[1] = field_ucd if field_ucd != 'nil' else thead << "<th>#{field_archive['name']}</th>\n" if field_ucd != 'nil' thead_2row.push(field_ucd) else thead_2row.push(' ') end end col_count += 1 end thead << " </tr>\n" thead << "<tr>\n" thead_2row.each do |h| thead << "<th>#{h}</th>\n" end thead << "</tr>\n" thead << "</thead>" return thead end |
#create_item_cart_params(cart_params, columns) ⇒ Object
Creates the cart parameters
- cart_params:
- columns:
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/voruby/votables/int.rb', line 199 def create_item_cart_params(cart_params, columns) link_ref_array = [] cart_params.each do |key, value| link_ref_array.push("#{key}=#{value}") end access_ref_index = image_access_reference_columns() link_ref_array.push("resource=#{CGI.escape(columns[access_ref_index].value).to_s}") if access_ref_index ra_index = image_ra_columns() link_ref_array.push("rac=#{columns[ra_index].value.to_s}") if ra_index dec_index = image_dec_columns() link_ref_array.push("decc=#{columns[dec_index].value.to_s}") if dec_index filter_index = image_filter_columns() link_ref_array.push("filter=#{columns[filter_index].value.to_s}") if filter_index date_obs_index = image_date_obs_columns() link_ref_array.push("date_obs=#{columns[date_obs_index].value.to_s}") if date_obs_index teles_index = image_telescope_columns() link_ref_array.push("telescop=#{columns[teles_index].value.to_s}") if teles_index survey_index = image_survey_columns() link_ref_array.push("survey=#{columns[survey_index].value.to_s}") if survey_index instrum_index = image_instrument_columns() link_ref_array.push("instrument=#{columns[instrum_index].value.to_s}") if instrum_index sky_index = image_sky_columns() link_ref_array.push("sky=#{columns[sky_index].value.to_s}") if sky_index zerop_index = image_zeropoint_columns() link_ref_array.push("zeropoint=#{columns[zerop_index].value.to_s}") if zerop_index seeing_index = image_seeing_columns() link_ref_array.push("seeing=#{columns[seeing_index].value.to_s}") if seeing_index depth_index = image_depth_columns() link_ref_array.push("depth=#{columns[depth_index].value.to_s}") if depth_index exptime_index = image_exptime_columns() link_ref_array.push("exptime=#{columns[exptime_index].value.to_s}") if exptime_index return link_ref_array.join('&') end |
#find_field_in_conf_file(key) ⇒ Object
Find a field in INT configuration file given a key. Returns a hash with the field’s attributes
- key:
-
The key indexing on field’s attribute
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/voruby/votables/int.rb', line 26 def find_field_in_conf_file(key) int_field = {'id'=> nil, 'name'=> nil, 'ucd'=> nil} if key != nil INT_ARCHIVE_CONFIG.each do |archive| archive['votable_fields'].each do |field| if field['key'] == key int_field['id'] = field['id'] if field['id'] != 'nil' int_field['name'] = field['name'] if field['name'] != 'nil' int_field['ucd'] = field['ucd'] if field['ucd'] != 'nil' break end end end end return int_field end |
#image_access_reference_columns ⇒ Object
Find the column number(s) associated with the VOX:imageAccessReference UCD. Returns a list of column positions.
47 48 49 50 51 52 53 |
# File 'lib/voruby/votables/int.rb', line 47 def image_access_reference_columns() ucd_access = find_field_in_conf_file('VOX:Image_AccessReference')['ucd'] if find_columns(ucd_access).first != nil find_columns(ucd_access).first end end |
#image_date_obs_columns ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/voruby/votables/int.rb', line 79 def image_date_obs_columns #ucd_date_obs = find_field_in_conf_file('')['ucd'] #if find_columns(ucd_date_obs).first != nil # find_columns(ucd_date_obs).first #end end |
#image_dec_columns ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/voruby/votables/int.rb', line 63 def image_dec_columns ucd_dec = find_field_in_conf_file('POS_EQ_DEC_MAIN')['ucd'] if find_columns(ucd_dec).first != nil find_columns(ucd_dec).first end end |
#image_depth_columns ⇒ Object
135 136 137 138 139 140 141 |
# File 'lib/voruby/votables/int.rb', line 135 def image_depth_columns #ucd_depth = find_field_in_conf_file('')['ucd'] #if find_columns(ucd_depth).first != nil # find_columns(ucd_depth).first #end end |
#image_exptime_columns ⇒ Object
143 144 145 146 147 148 149 |
# File 'lib/voruby/votables/int.rb', line 143 def image_exptime_columns #ucd_exptime = find_field_in_conf_file('')['ucd'] #if find_columns(ucd_exptime).first != nil # find_columns(ucd_exptime).first #end end |
#image_filter_columns ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/voruby/votables/int.rb', line 71 def image_filter_columns ucd_filter = find_field_in_conf_file('VOX:BandPass_ID')['ucd'] if find_columns(ucd_filter).first != nil find_columns(ucd_filter).first end end |
#image_instrument_columns ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/voruby/votables/int.rb', line 103 def image_instrument_columns ucd_instrument = find_field_in_conf_file('VOX:INST_ID')['ucd'] if find_columns(ucd_instrument).first != nil find_columns(ucd_instrument).first end end |
#image_ra_columns ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/voruby/votables/int.rb', line 55 def image_ra_columns ucd_ra = find_field_in_conf_file('POS_EQ_RA_MAIN')['ucd'] if find_columns(ucd_ra).first != nil find_columns(ucd_ra).first end end |
#image_seeing_columns ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/voruby/votables/int.rb', line 127 def image_seeing_columns #ucd_seeing = find_field_in_conf_file('')['ucd'] #if find_columns(ucd_seeing).first != nil # find_columns(ucd_seeing).first #end end |
#image_sky_columns ⇒ Object
111 112 113 114 115 116 117 |
# File 'lib/voruby/votables/int.rb', line 111 def image_sky_columns #ucd_sky = find_field_in_conf_file('')['ucd'] #if find_columns(ucd_sky).first != nil # find_columns(ucd_sky).first #end end |
#image_survey_columns ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/voruby/votables/int.rb', line 95 def image_survey_columns ucd_survey = find_field_in_conf_file('VOX:Image_title')['ucd'] if find_columns(ucd_survey).first != nil find_columns(ucd_survey).first end end |
#image_telescope_columns ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/voruby/votables/int.rb', line 87 def image_telescope_columns #ucd_telescope = find_field_in_conf_file('')['ucd'] #if find_columns(ucd_telescope).first != nil # find_columns(ucd_telescope).first #end end |
#image_zeropoint_columns ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/voruby/votables/int.rb', line 119 def image_zeropoint_columns #ucd_zeropoint = find_field_in_conf_file('')['ucd'] #if find_columns(ucd_zeropoint).first != nil # find_columns(ucd_zeropoint).first #end end |
#to_html(options = {}) ⇒ Object
Convert the specified table in the specified resource into an HTML table.
- options:
-
The options for this VOTable.
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
# File 'lib/voruby/votables/int.rb', line 291 def to_html(={}) # The ID to assign to the HTML table as a whole. [:id] = [:id] || "#{votable}_#{Time.now.to_i}_#{rand(10000)}" [:infer_add_to_cart_ref] = true if [:infer_add_to_cart_ref] == nil [:add_to_cart_header_label] = [:add_to_cart_header_label] || 'Add to Cart' [:cart_params] = {} if [:cart_params] == nil #options[:add_to_cart_url] = options[:add_to_cart_url] || nil [:throbber_src] = [:throbber_src] || '/images/general/indicator.gif' [:throbber_size] = [:throbber_size] || '16x16' [:throbber_class] = [:throbber_class] || 'throbber' [:throbber_id] = [:throbber_id] || "#{[:id]}_throbber_id" [:flash_notice_class] = [:flash_notice_class] || 'flash_notice' [:flash_notice_id] = [:flash_notice_id] || "#{[:id]}_flash_notice_id" # Link the access reference URL associated with a row. [:infer_access_ref] = true if [:infer_access_ref] == nil #options[:retrieve_link_ref] = options[:retrieve_link_ref] || nil # For the access reference column, place this value in the header. [:access_ref_header_label] = [:access_ref_header_label] || 'URL' # For the access reference column, link this word. [:access_ref_link_label] = [:access_ref_link_label] || 'Retrieve' [:ssl] = false if [:ssl] == nil #options[:resource_link] = options[:resource_link] # The resource from which to extract the table in question. [:res] = [:res] || 0 # The table inside the resource from which to extract the rows in question. [:tbl] = [:tbl] || 0 # The boolean value to show HTML table border [:show_border] = false if [:show_border] == nil # The class to assign the HTML table as a whole. [:table_class] = [:table_class] || 'votable' # The class to assign the header of the HTML table. [:header_class] = [:header_class] || 'header' # The class to assign the body of the HTML table. [:body_class] = [:body_class] || 'body' # The class to assign the HTML table body rows. [:row_classes] = [:row_classes] || ['row1', 'row2'] begin # A valid SIA VOTable will only ever have one VOX:Image_AccessReference. access_ref_index = image_access_reference_columns() return create_votable(create_headers(access_ref_index, ), create_body(access_ref_index, ), ) rescue Exception => e title = 'Error...' = "VORuby error: #{e.}<br>#{e.backtrace}" << "<br>#{@resources[0].info[0].text().to_s()}" if @resources[0].info[0] (title, , ) end end |