Class: VORuby::ADQL::V1_0::JoinTable

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

Overview

Represents SQL JOIN expression

Defined Under Namespace

Classes: ListOfFromTable

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(qualifier, tables, condition) ⇒ JoinTable

Returns a new instance of JoinTable.



910
911
912
913
914
# File 'lib/voruby/adql/1.0/adql.rb', line 910

def initialize(qualifier, tables, condition)
  self.qualifier = qualifier
  self.tables = tables
  self.condition = condition
end

Instance Attribute Details

#conditionObject

Returns the value of attribute condition.



906
907
908
# File 'lib/voruby/adql/1.0/adql.rb', line 906

def condition
  @condition
end

#qualifierObject

Returns the value of attribute qualifier.



906
907
908
# File 'lib/voruby/adql/1.0/adql.rb', line 906

def qualifier
  @qualifier
end

#tablesObject

Returns the value of attribute tables.



906
907
908
# File 'lib/voruby/adql/1.0/adql.rb', line 906

def tables
  @tables
end

Class Method Details

.from_xml(xml) ⇒ Object



965
966
967
968
969
970
971
972
973
974
975
# File 'lib/voruby/adql/1.0/adql.rb', line 965

def self.from_xml(xml)
  root = element_from(xml)
  
  self.new(
    JointTableQualifier.new(REXML::XPath.first(root, 'x:Qualifier', {'x' => obj_ns.uri}).text),
    JoinTable::ListOfFromTable.new(
      REXML::XPath.match(root, 'x:Table', {'x' => obj_ns.uri}).collect{ |tel| xml_to_obj(tel) }
    ),
    xml_to_obj(REXML::XPath.first(root, 'x:Condition', {'x' => obj_ns.uri}))
  )
end

.xml_typeObject



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

def self.xml_type; 'joinTableType' end

Instance Method Details

#==(t) ⇒ Object



940
941
942
943
944
# File 'lib/voruby/adql/1.0/adql.rb', line 940

def ==(t)
  self.qualifier == t.qualifier and
  self.tables == t.tables and
  self.condition == t.condition
end

#to_sObject



946
947
948
# File 'lib/voruby/adql/1.0/adql.rb', line 946

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

#to_xml(name = nil) ⇒ Object



950
951
952
953
954
955
956
957
958
959
960
961
962
963
# File 'lib/voruby/adql/1.0/adql.rb', line 950

def to_xml(name=nil)
  el = super(name)
  
  qualifier = REXML::Element.new("#{obj_ns.prefix}:Qualifier")
  qualifier.text = self.qualifier.to_s
  el.add_element(qualifier)
  
  self.tables.collect{ |t| el.add_element(t.to_xml('Table')) }
  
  el.add_element(self.condition.to_xml('Condition'))
  
  collapse_namespaces(el)
  el
end