Class: VORuby::ADQL::AliasSelectionItem

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

Overview

Used to select an expression as a new alias column.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expression, as = nil) ⇒ AliasSelectionItem

Returns a new instance of AliasSelectionItem.



726
727
728
729
# File 'lib/voruby/adql/adql.rb', line 726

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

Instance Attribute Details

#asObject

Returns the value of attribute as.



724
725
726
# File 'lib/voruby/adql/adql.rb', line 724

def as
  @as
end

#expressionObject

Returns the value of attribute expression.



723
724
725
# File 'lib/voruby/adql/adql.rb', line 723

def expression
  @expression
end

Class Method Details

.from_xml(node) ⇒ Object



745
746
747
748
749
750
# File 'lib/voruby/adql/adql.rb', line 745

def self.from_xml(node)
 as = node.attributes['As']
 expr_node = REXML::XPath.first(node, 'Expression')
 expr = ScalarExpression.from_xml(expr_node)
 return AliasSelectionItem.new(expr, as)
end

Instance Method Details

#to_adqlsObject



153
154
155
156
157
158
159
# File 'lib/voruby/adql/transforms.rb', line 153

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

#to_sObject



741
742
743
# File 'lib/voruby/adql/adql.rb', line 741

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