Class: VORuby::Simple::ConeSearch
- Includes:
- HTTPGetQuery, VOTableMarshaller
- Defined in:
- lib/voruby/simple/sap.rb
Overview
Represents a query to a cone search server.
mast_cone = Simple::ConeSearch.new('http://archive.stsci.edu/hst/search.php',
53.084, -27.873, 0.01, nil, 30, ‘rexml’)
mast_cone.fetch()
votable = mast_cone.marshall()
Instance Attribute Summary collapse
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#parser ⇒ Object
Returns the value of attribute parser.
-
#query_timeout ⇒ Object
Returns the value of attribute query_timeout.
-
#response ⇒ Object
Returns the value of attribute response.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
-
#dec(dec = nil) ⇒ Object
Set or get the value of the dec.
-
#initialize(uri, ra, dec, radius, parameters = {}, query_timeout = 30, parser = 'rexml') ⇒ ConeSearch
constructor
- uri:
-
The base URI of the cone service.
-
#ra(ra = nil) ⇒ Object
Set or get the value of the RA.
-
#radius(radius = nil) ⇒ Object
Set or get the value of the search radius (in degrees).
-
#required_parameters ⇒ Object
Retrieve the list of required parameters.
-
#to_s ⇒ Object
Convert the query into a valid URL.
Methods included from VOTableMarshaller
Methods included from HTTPGetQuery
Constructor Details
#initialize(uri, ra, dec, radius, parameters = {}, query_timeout = 30, parser = 'rexml') ⇒ ConeSearch
- uri:
-
The base URI of the cone service.
- ra:
-
The right ascension search center of the query. May be a floating point number (in degrees), or a full Simple::Parameters::RightAscension object.
- dec:
-
The declination search center of the query. May be a floating point number (in degrees), or a full Simple::Parameters::Declination object.
- radius:
-
The size of the search radius in degrees.
- parameters:
-
A hash of extra parameters to pass to the cone service. Typically this list is empty, but some cone servers permit “extra” parameters to be used.
- :query_timeout:
-
Period of time to wait until the remote host don’t respond.
- parser:
-
A string representing the underlying XML parser to use. Choices right now are ‘rexml’ and ‘libxml’. rexml ships with Ruby, but is slow. libxml is much faster, but of course must be installed separately.
177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/voruby/simple/sap.rb', line 177 def initialize(uri, ra, dec, radius, parameters={}, query_timeout=30, parser='rexml') parameters ||= {} @uri = uri ra(ra) dec(dec) radius(radius) @parameters = parameters @query_timeout = query_timeout @parser = parser @response = nil end |
Instance Attribute Details
#parameters ⇒ Object
Returns the value of attribute parameters.
152 153 154 |
# File 'lib/voruby/simple/sap.rb', line 152 def parameters @parameters end |
#parser ⇒ Object
Returns the value of attribute parser.
152 153 154 |
# File 'lib/voruby/simple/sap.rb', line 152 def parser @parser end |
#query_timeout ⇒ Object
Returns the value of attribute query_timeout.
152 153 154 |
# File 'lib/voruby/simple/sap.rb', line 152 def query_timeout @query_timeout end |
#response ⇒ Object
Returns the value of attribute response.
152 153 154 |
# File 'lib/voruby/simple/sap.rb', line 152 def response @response end |
#uri ⇒ Object
Returns the value of attribute uri.
152 153 154 |
# File 'lib/voruby/simple/sap.rb', line 152 def uri @uri end |
Instance Method Details
#dec(dec = nil) ⇒ Object
Set or get the value of the dec. Allows a lazy mode where a string representing the declination is passed in instead of a full Simple::Parameters::Declination object.
213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/voruby/simple/sap.rb', line 213 def dec(dec=nil) if dec == nil return @dec else if dec.instance_of?(Parameters::Declination) @dec = dec elsif dec.instance_of?(String) or dec.instance_of?(Float) or dec.instance_of?(Fixnum) @dec = Parameters::Declination.new(dec) else raise "Declination must be a Declination object or an interparable string." end end end |
#ra(ra = nil) ⇒ Object
Set or get the value of the RA. Allows a lazy mode where a string representing the right ascension is passed in instead of a full Simple::Parameters::RightAscension object.
195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/voruby/simple/sap.rb', line 195 def ra(ra=nil) if ra == nil return @ra else if ra.instance_of?(Parameters::RightAscension) @ra = ra elsif ra.instance_of?(String) or ra.instance_of?(Float) or ra.instance_of?(Fixnum) @ra = Parameters::RightAscension.new(ra) else raise "Right ascension must be RightAscension object or an interparable string." end end end |
#radius(radius = nil) ⇒ Object
Set or get the value of the search radius (in degrees). Allows a lazy mode where an integer representing the radius is passed in instead of a full Simple::Parameters::Radius object.
231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/voruby/simple/sap.rb', line 231 def radius(radius=nil) if radius == nil return @radius else if radius.instance_of?(Parameters::Radius) @radius = radius else @radius = Parameters::Radius.new(radius) end end end |
#required_parameters ⇒ Object
Retrieve the list of required parameters. In this case: ra, dec and radius.
244 245 246 |
# File 'lib/voruby/simple/sap.rb', line 244 def required_parameters [@ra.to_s(), @dec.to_s(), @radius.to_s()] end |
#to_s ⇒ Object
Convert the query into a valid URL.
249 250 251 |
# File 'lib/voruby/simple/sap.rb', line 249 def to_s query_uri() end |