Class: VORuby::ADQL::Order

Inherits:
Object show all
Defined in:
lib/voruby/adql/adql.rb,
lib/voruby/adql/transforms.rb

Overview

Represents the ORDER BY part of a query.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expression, order = nil) ⇒ Order

Returns a new instance of Order.



2283
2284
2285
2286
# File 'lib/voruby/adql/adql.rb', line 2283

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

Instance Attribute Details

#expressionObject

Returns the value of attribute expression.



2281
2282
2283
# File 'lib/voruby/adql/adql.rb', line 2281

def expression
  @expression
end

#orderObject

Returns the value of attribute order.



2281
2282
2283
# File 'lib/voruby/adql/adql.rb', line 2281

def order
  @order
end

Class Method Details

.from_xml(node) ⇒ Object



2307
2308
2309
2310
2311
2312
2313
# File 'lib/voruby/adql/adql.rb', line 2307

def self.from_xml(node)
  expr_node = REXML::XPath.first(node, 'Expression')
  expr = Expression.from_xml(expr_node)
  order_option_node = REXML::XPath.first(node, 'Order')
  order_option = OrderOption.from_xml(order_option_node)
  return Order.new(expr, order_option)
end

Instance Method Details

#to_adqlsObject



460
461
462
463
464
465
466
# File 'lib/voruby/adql/transforms.rb', line 460

def to_adqls
  if self.order
    "#{self.expression.to_adqls} #{self.order.to_adqls}"
  else
    "#{self.expression.to_adqls}"
  end
end

#to_sObject



2303
2304
2305
# File 'lib/voruby/adql/adql.rb', line 2303

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