Class: VORuby::ADQL::V1_0::From

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

Overview

Represents the From part of the query

Defined Under Namespace

Classes: TableList

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(tables) ⇒ From

Returns a new instance of From.



1703
1704
1705
# File 'lib/voruby/adql/1.0/adql.rb', line 1703

def initialize(tables)
  self.tables = tables
end

Instance Attribute Details

#tablesObject

Returns the value of attribute tables.



1694
1695
1696
# File 'lib/voruby/adql/1.0/adql.rb', line 1694

def tables
  @tables
end

Class Method Details

.from_xml(xml) ⇒ Object



1733
1734
1735
1736
1737
1738
1739
1740
1741
# File 'lib/voruby/adql/1.0/adql.rb', line 1733

def self.from_xml(xml)
  root = element_from(xml)
  
  self.new(
    From::TableList.new(
      REXML::XPath.match(root, 'x:Table', {'x' => obj_ns.uri}).collect{ |tel| xml_to_obj(tel) }
    )
  )
end

.xml_typeObject



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

def self.xml_type; 'fromType' end

Instance Method Details

#==(f) ⇒ Object



1716
1717
1718
# File 'lib/voruby/adql/1.0/adql.rb', line 1716

def ==(f)
  self.tables == f.tables
end

#to_sObject



1720
1721
1722
# File 'lib/voruby/adql/1.0/adql.rb', line 1720

def to_s
  "FROM #{self.tables.collect{ |t| t.to_s }.join(', ')}"
end

#to_xml(name = nil) ⇒ Object



1724
1725
1726
1727
1728
1729
1730
1731
# File 'lib/voruby/adql/1.0/adql.rb', line 1724

def to_xml(name=nil)
  el = element_root(name)
  
  self.tables.each { |t| el.add_element(t.to_xml('Table')) }
  
  collapse_namespaces(el)
  el
end