Class: VORuby::ADQL::V1_0::Order

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

Overview

Represents the ORDER BY part of a query

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(expression, order = nil) ⇒ Order

Returns a new instance of Order.



1942
1943
1944
1945
# File 'lib/voruby/adql/1.0/adql.rb', line 1942

def initialize(expression, order=nil)
  self.expression = expression
  self.order = order
end

Instance Attribute Details

#expressionObject

Returns the value of attribute expression.



1940
1941
1942
# File 'lib/voruby/adql/1.0/adql.rb', line 1940

def expression
  @expression
end

#orderObject

Returns the value of attribute order.



1940
1941
1942
# File 'lib/voruby/adql/1.0/adql.rb', line 1940

def order
  @order
end

Class Method Details

.from_xml(xml) ⇒ Object



1979
1980
1981
1982
1983
1984
1985
1986
1987
# File 'lib/voruby/adql/1.0/adql.rb', line 1979

def self.from_xml(xml)
  root = element_from(xml)
  
  order_el = REXML::XPath.first(root, 'x:Order', {'x' => obj_ns.uri})
  self.new(
    xml_to_obj(REXML::XPath.first(root, 'x:Expression', {'x' => obj_ns.uri})),
    order_el ? xml_to_obj(order_el) : nil
  )
end

.xml_typeObject



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

def self.xml_type; 'orderType' end

Instance Method Details

#==(o) ⇒ Object



1958
1959
1960
1961
# File 'lib/voruby/adql/1.0/adql.rb', line 1958

def ==(o)
  self.expression == o.expression and
  self.order == o.order
end

#to_sObject



1963
1964
1965
1966
1967
# File 'lib/voruby/adql/1.0/adql.rb', line 1963

def to_s
  s = self.expression.to_s
  s = "#{s} #{self.order}" if self.order
  s
end

#to_xml(name = nil) ⇒ Object



1969
1970
1971
1972
1973
1974
1975
1976
1977
# File 'lib/voruby/adql/1.0/adql.rb', line 1969

def to_xml(name=nil)
  el = element_root(name)
  
  el.add_element(self.expression.to_xml('Expression'))
  el.add_element(self.order.to_xml('Order')) if self.order
  
  collapse_namespaces(el)
  el
end