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.
1744 1745 1746 1747 1748 1749 1750 1751 |
# File 'lib/voruby/adql/adql.rb', line 1744 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.
1742 1743 1744 |
# File 'lib/voruby/adql/adql.rb', line 1742 def ddec @ddec end |
#dec ⇒ Object
Returns the value of attribute dec.
1742 1743 1744 |
# File 'lib/voruby/adql/adql.rb', line 1742 def dec @dec end |
#dra ⇒ Object
Returns the value of attribute dra.
1742 1743 1744 |
# File 'lib/voruby/adql/adql.rb', line 1742 def dra @dra end |
#ra ⇒ Object
Returns the value of attribute ra.
1742 1743 1744 |
# File 'lib/voruby/adql/adql.rb', line 1742 def ra @ra end |
#shape ⇒ Object
Returns the value of attribute shape.
1742 1743 1744 |
# File 'lib/voruby/adql/adql.rb', line 1742 def shape @shape end |
#system ⇒ Object
Returns the value of attribute system.
1742 1743 1744 |
# File 'lib/voruby/adql/adql.rb', line 1742 def system @system end |
Class Method Details
.create_new_object(attributes) ⇒ Object
1834 1835 1836 1837 1838 1839 1840 1841 |
# File 'lib/voruby/adql/adql.rb', line 1834 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
1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 |
# File 'lib/voruby/adql/adql.rb', line 1818 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
1843 1844 1845 1846 1847 1848 1849 |
# File 'lib/voruby/adql/adql.rb', line 1843 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
1813 1814 1815 1816 |
# File 'lib/voruby/adql/adql.rb', line 1813 def to_s "{shape=#{self.shape},system=#{self.system},ra=#{self.ra}," + "dec=#{self.dec},dra=#{self.dra},ddec=#{self.ddec}}" end |