Class: VORuby::ADQL::Circle
- Defined in:
- lib/voruby/adql/adql.rb,
lib/voruby/adql/transforms.rb
Overview
Circle shape. The circle is defined by a center and a radius
Instance Attribute Summary collapse
-
#dec ⇒ Object
Returns the value of attribute dec.
-
#ra ⇒ Object
Returns the value of attribute ra.
-
#radius ⇒ Object
Returns the value of attribute radius.
-
#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, radius, system = 'J2000') ⇒ Circle
constructor
A new instance of Circle.
- #match_attributtes(attributes) ⇒ Object
- #to_adqls ⇒ Object
- #to_adqlx ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(ra, dec, radius, system = 'J2000') ⇒ Circle
Returns a new instance of Circle.
1648 1649 1650 1651 1652 1653 1654 |
# File 'lib/voruby/adql/adql.rb', line 1648 def initialize(ra, dec, radius, system='J2000') self.ra = ra self.dec = dec self.radius = radius self.system = system self.shape = 'CIRCLE' end |
Instance Attribute Details
#dec ⇒ Object
Returns the value of attribute dec.
1646 1647 1648 |
# File 'lib/voruby/adql/adql.rb', line 1646 def dec @dec end |
#ra ⇒ Object
Returns the value of attribute ra.
1646 1647 1648 |
# File 'lib/voruby/adql/adql.rb', line 1646 def ra @ra end |
#radius ⇒ Object
Returns the value of attribute radius.
1646 1647 1648 |
# File 'lib/voruby/adql/adql.rb', line 1646 def radius @radius end |
#shape ⇒ Object
Returns the value of attribute shape.
1646 1647 1648 |
# File 'lib/voruby/adql/adql.rb', line 1646 def shape @shape end |
#system ⇒ Object
Returns the value of attribute system.
1646 1647 1648 |
# File 'lib/voruby/adql/adql.rb', line 1646 def system @system end |
Class Method Details
.create_new_object(attributes) ⇒ Object
1724 1725 1726 1727 1728 1729 1730 |
# File 'lib/voruby/adql/adql.rb', line 1724 def self.create_new_object(attributes) ra = RealType.new(attributes['ra']) dec = RealType.new(attributes['dec']) radius = RealType.new(attributes['radius']) return Circle.new(ra, dec, radius) end |
.from_xml(node) ⇒ Object
1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 |
# File 'lib/voruby/adql/adql.rb', line 1710 def self.from_xml(node) unit = node.attributes['unit'] || 'deg' center = REXML::XPath.first(node, 'reg:Center', {'reg' => 'http://www.ivoa.net/xml/STC/STCregion/v1.10'}).text ra_s, dec_s = center.split(/\s+/) ra = RealType.new(ra_s.to_f) dec = RealType.new(dec_s.to_f) radius_s = REXML::XPath.first(node, 'reg:Radius', {'reg' => 'http://www.ivoa.net/xml/STC/STCregion/v1.10'}).text radius = RealType.new(radius_s.to_f) return Circle.new(ra, dec, radius) end |
Instance Method Details
#match_attributtes(attributes) ⇒ Object
1732 1733 1734 1735 1736 1737 |
# File 'lib/voruby/adql/adql.rb', line 1732 def match_attributtes(attributes) return true if self.ra.value == attributes['ra'] and self.dec.value == attributes['dec'] and self.radius.value == attributes['radius'] return false end |
#to_adqls ⇒ Object
328 329 330 |
# File 'lib/voruby/adql/transforms.rb', line 328 def to_adqls "#{self.shape.to_adqls} #{self.system.to_adqls} #{self.ra.to_adqls} #{self.dec.to_adqls} #{self.radius.to_adqls}" end |
#to_adqlx ⇒ Object
332 333 334 335 336 337 |
# File 'lib/voruby/adql/transforms.rb', line 332 def to_adqlx circle = "xsi:type=\"reg:circleType\" unit=\"deg\">\n" circle << "<reg:Center>#{self.ra.value} #{self.dec.value}</reg:Center>\n" circle << "<reg:Radius>#{self.radius.value}</reg:Radius>\n" return circle end |
#to_s ⇒ Object
1706 1707 1708 |
# File 'lib/voruby/adql/adql.rb', line 1706 def to_s "{shape=#{self.shape},system=#{self.system},ra=#{self.ra},dec=#{self.dec},radius=#{self.radius}}" end |