Class: VORuby::Simple::SpectralAccess

Inherits:
Object
  • Object
show all
Includes:
HTTPGetQuery, VOTableMarshaller
Defined in:
lib/voruby/simple/sap.rb

Overview

Represents a query to single SSAP server.

iso_ssap = Simple::SpectralAccess.new('http://pma.iso.vilspa.esa.es:8080/aio/jsp/siap.jsp',

‘53.084, -27.873’, 10, => ‘votable’, 30, ‘rexml’)

iso_ssap.fetch()
votable = iso_ssap.marshall()

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from VOTableMarshaller

#marshall

Methods included from HTTPGetQuery

#fetch, #query_uri

Constructor Details

#initialize(uri, pos, size, parameters = {}, query_timeout = 30, parser = 'rexml') ⇒ SpectralAccess

right now are ‘rexml’ and ‘libxml’. rexml ships with Ruby, but is

slow.  libxml is much faster, but of course must be installed
separately.


283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/voruby/simple/sap.rb', line 283

def initialize(uri, pos, size, parameters={}, query_timeout=30, parser='rexml')
  parameters ||= {}

  @uri = uri
  pos(pos)
  size(size)
  @parameters = parameters
  @query_timeout = query_timeout
  @parser = parser

  @response = nil
end

Instance Attribute Details

#parametersObject

Returns the value of attribute parameters.



264
265
266
# File 'lib/voruby/simple/sap.rb', line 264

def parameters
  @parameters
end

#parserObject

Returns the value of attribute parser.



264
265
266
# File 'lib/voruby/simple/sap.rb', line 264

def parser
  @parser
end

#query_timeoutObject

Returns the value of attribute query_timeout.



264
265
266
# File 'lib/voruby/simple/sap.rb', line 264

def query_timeout
  @query_timeout
end

#responseObject

Returns the value of attribute response.



264
265
266
# File 'lib/voruby/simple/sap.rb', line 264

def response
  @response
end

#uriObject

Returns the value of attribute uri.



264
265
266
# File 'lib/voruby/simple/sap.rb', line 264

def uri
  @uri
end

Instance Method Details

#pos(pos = nil) ⇒ Object

Set or get the value of the position. Allows a lazy mode where a string representing the position like ‘53.084, -27.873’is passed in instead of a full Position object.



300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/voruby/simple/sap.rb', line 300

def pos(pos=nil)
  if pos == nil
  		return @pos
  else
# Position.  Allow a lazy mode where a string representing
# the position is passed in instead of a full Position object.
  		if pos.instance_of?(Parameters::Position)
	@pos = pos
  		elsif pos.instance_of?(String)
	ra_dec, dec_dec = pos.split(/\s*,\s*/)
	@pos = Parameters::Position.new(ra_dec, dec_dec)
  		else
raise "Position must be a Position object or a string like " +
 	"'ra_in_decimal_degrees, dec_in_decimal_degrees'"
  		end
  end
end

#required_parametersObject

Retrieve the list of required parameters. In this case: pos and size.



340
341
342
# File 'lib/voruby/simple/sap.rb', line 340

def required_parameters
  [@pos.to_s(), @size.to_s()]
end

#size(size = nil) ⇒ Object

Set or get the value of the angular size. Allows a lazy mode where a floating point number representing the size is passed in instead of a full Size object.



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/voruby/simple/sap.rb', line 321

def size(size=nil)
  if size == nil
  		return @size
  else
  		if size.instance_of?(Parameters::Size)
	@size = size
  		elsif size.instance_of?(String)
	ra_width, dec_width = size.split(/\s*,\s*/)
	@size = Parameters::Size.new(ra_width, dec_width)
  		elsif size.instance_of?(Float) or size.instance_of?(Fixnum)
	@size = Parameters::Size.new(size.to_f())
  		else
	raise "Size must be a Size object or a string like " +
 		"'ra_width_in_decimal_degrees, dec_width_in_decimal_degrees'"
  		end
  end
end

#to_sObject

Convert the query into a valid URL.



345
346
347
# File 'lib/voruby/simple/sap.rb', line 345

def to_s
  query_uri()
end