Class: VORuby::ADQL::V1_0::RegionSearch

Inherits:
Search
  • Object
show all
Defined in:
lib/voruby/adql/1.0/adql.rb

Overview

Represents the Regions such as circle in Where clause

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(region) ⇒ RegionSearch

Returns a new instance of RegionSearch.



1506
1507
1508
# File 'lib/voruby/adql/1.0/adql.rb', line 1506

def initialize(region)
  self.region = region
end

Instance Attribute Details

#regionObject

Returns the value of attribute region.



1502
1503
1504
# File 'lib/voruby/adql/1.0/adql.rb', line 1502

def region
  @region
end

Class Method Details

.from_xml(xml) ⇒ Object



1539
1540
1541
1542
1543
1544
1545
# File 'lib/voruby/adql/1.0/adql.rb', line 1539

def self.from_xml(xml)
  root = element_from(xml)
  
  self.new(
    xml_to_obj(REXML::XPath.first(root, 'x:Region', {'x' => obj_ns('VORuby::STC::V1_10::Region').uri}))
  )
end

.xml_typeObject



1504
# File 'lib/voruby/adql/1.0/adql.rb', line 1504

def self.xml_type; 'regionSearchType' end

Instance Method Details

#==(s) ⇒ Object



1516
1517
1518
# File 'lib/voruby/adql/1.0/adql.rb', line 1516

def ==(s)
  self.region == s.region
end

#to_sObject



1520
1521
1522
# File 'lib/voruby/adql/1.0/adql.rb', line 1520

def to_s
  "REGION(#{self.region})"
end

#to_xml(name = nil) ⇒ Object



1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
# File 'lib/voruby/adql/1.0/adql.rb', line 1524

def to_xml(name=nil)
  el = super(name)
  
  reg_ns = obj_ns('VORuby::STC::V1_10::Region')
  el.add_namespace(reg_ns.prefix, reg_ns.uri)
  
  reg = el.add_element(self.region.to_xml('Region'))
  
  raise "unable to determine xsi:type of region #{self.region.inspect}" if !self.region.class.respond_to?(:xml_type)
  reg.attributes["#{XSI_NAMESPACE.prefix}:type"] = "#{reg_ns.prefix}:#{self.region.class.xml_type}"
  
  collapse_namespaces(el)
  el
end