Class: VORuby::ADQL::V1_0::GroupBy

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

Overview

Represents the Group By expression part of a query

Defined Under Namespace

Classes: ColumnList

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(columns) ⇒ GroupBy

Returns a new instance of GroupBy.



1605
1606
1607
# File 'lib/voruby/adql/1.0/adql.rb', line 1605

def initialize(columns)
  self.columns = columns
end

Instance Attribute Details

#columnsObject

Returns the value of attribute columns.



1601
1602
1603
# File 'lib/voruby/adql/1.0/adql.rb', line 1601

def columns
  @columns
end

Class Method Details

.from_xml(xml) ⇒ Object



1635
1636
1637
1638
1639
1640
1641
1642
1643
# File 'lib/voruby/adql/1.0/adql.rb', line 1635

def self.from_xml(xml)
  root = element_from(xml)
  
  self.new(
    GroupBy::ColumnList.new(
      REXML::XPath.match(root, 'x:Column', {'x' => obj_ns.uri}).collect{ |cel| xml_to_obj(cel) }
    )
  )
end

.xml_typeObject



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

def self.xml_type; 'groupByType' end

Instance Method Details

#==(g) ⇒ Object



1618
1619
1620
# File 'lib/voruby/adql/1.0/adql.rb', line 1618

def ==(g)
  self.columns == g.columns
end

#to_sObject



1622
1623
1624
# File 'lib/voruby/adql/1.0/adql.rb', line 1622

def to_s
  "GROUP BY #{self.columns.collect{ |c| c.to_s }.join(', ')}"
end

#to_xml(name = nil) ⇒ Object



1626
1627
1628
1629
1630
1631
1632
1633
# File 'lib/voruby/adql/1.0/adql.rb', line 1626

def to_xml(name=nil)
  el = element_root(name)
  
  self.columns.each{ |c| el.add_element(c.to_xml('Column')) }
  
  collapse_namespaces(el)
  el
end