Class: VORuby::ADQL::Box
- Defined in:
- lib/voruby/adql/adql.rb,
lib/voruby/adql/transforms.rb
Overview
Box shape. The box is defined by a center and a size
Instance Attribute Summary collapse
-
#ddec ⇒ Object
Returns the value of attribute ddec.
-
#dec ⇒ Object
Returns the value of attribute dec.
-
#dra ⇒ Object
Returns the value of attribute dra.
-
#ra ⇒ Object
Returns the value of attribute ra.
-
#shape ⇒ Object
Returns the value of attribute shape.
-
#system ⇒ Object
Returns the value of attribute system.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ra, dec, dra, ddec, system = 'J2000') ⇒ Box
constructor
A new instance of Box.
- #match_attributtes(attributes) ⇒ Object
- #to_adqls ⇒ Object
- #to_adqlx ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(ra, dec, dra, ddec, system = 'J2000') ⇒ Box
Returns a new instance of Box.
1784 1785 1786 1787 1788 1789 1790 1791 |
# File 'lib/voruby/adql/adql.rb', line 1784 def initialize(ra, dec, dra, ddec, system='J2000') self.ra = ra self.dec = dec self.dra = dra#deltha RA self.ddec = ddec#deltha DEC self.system = system self.shape = 'BOX' end |
Instance Attribute Details
#ddec ⇒ Object
Returns the value of attribute ddec.
1782 1783 1784 |
# File 'lib/voruby/adql/adql.rb', line 1782 def ddec @ddec end |
#dec ⇒ Object
Returns the value of attribute dec.
1782 1783 1784 |
# File 'lib/voruby/adql/adql.rb', line 1782 def dec @dec end |
#dra ⇒ Object
Returns the value of attribute dra.
1782 1783 1784 |
# File 'lib/voruby/adql/adql.rb', line 1782 def dra @dra end |
#ra ⇒ Object
Returns the value of attribute ra.
1782 1783 1784 |
# File 'lib/voruby/adql/adql.rb', line 1782 def ra @ra end |
#shape ⇒ Object
Returns the value of attribute shape.
1782 1783 1784 |
# File 'lib/voruby/adql/adql.rb', line 1782 def shape @shape end |
#system ⇒ Object
Returns the value of attribute system.
1782 1783 1784 |
# File 'lib/voruby/adql/adql.rb', line 1782 def system @system end |
Class Method Details
.create_new_object(attributes) ⇒ Object
1874 1875 1876 1877 1878 1879 1880 1881 |
# File 'lib/voruby/adql/adql.rb', line 1874 def self.create_new_object(attributes) ra = RealType.new(attributes['ra']) dec = RealType.new(attributes['dec']) dra = RealType.new(attributes['dra']) ddec = RealType.new(attributes['ddec']) return Box.new(ra, dec, dra, ddec) end |
.from_xml(node) ⇒ Object
1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 |
# File 'lib/voruby/adql/adql.rb', line 1858 def self.from_xml(node) unit = node.attributes['unit'] || 'deg' center = REXML::XPath.first(node, 'reg:Center').text ra_s, dec_s = center.split(/\s+/) ra = RealType.new(ra_s.to_f) dec = RealType.new(dec_s.to_f) size = REXML::XPath.first(node, 'reg:Size').text dra_s, ddec_s = size.split(/\s+/) dra = RealType.new(dra_s.to_f) ddec = RealType.new(ddec_s.to_f) return Box.new(ra, dec, dra, ddec) end |
Instance Method Details
#match_attributtes(attributes) ⇒ Object
1883 1884 1885 1886 1887 1888 1889 |
# File 'lib/voruby/adql/adql.rb', line 1883 def match_attributtes(attributes) return true if self.ra.value == attributes['ra'] and self.dec.value == attributes['dec'] and self.dra.value == attributes['dra'] and self.ddec.value == attributes['ddec'] return false end |
#to_adqls ⇒ Object
341 342 343 344 345 |
# File 'lib/voruby/adql/transforms.rb', line 341 def to_adqls "#{self.shape.to_adqls} #{self.system.to_adqls} " + "#{self.ra.to_adqls} #{self.dec.to_adqls} " + "#{self.dra.to_adqls} #{self.ddec.to_adqls}" end |
#to_adqlx ⇒ Object
347 348 349 350 351 352 |
# File 'lib/voruby/adql/transforms.rb', line 347 def to_adqlx box = "xsi:type=\"reg:boxType\">\n" box << "<reg:Center>#{self.ra.value} #{self.dec.value}</reg:Center>\n" box << "<reg:Size>#{self.dra.value} #{self.ddec.value}</reg:Size>\n" return box end |
#to_s ⇒ Object
1853 1854 1855 1856 |
# File 'lib/voruby/adql/adql.rb', line 1853 def to_s "{shape=#{self.shape},system=#{self.system},ra=#{self.ra}," + "dec=#{self.dec},dra=#{self.dra},ddec=#{self.ddec}}" end |