Class: VORuby::ADQL::BinaryExpr

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

Overview

Represents a binary expression such as a+b.

Instance Attribute Summary collapse

Attributes inherited from ScalarExpression

#value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ScalarExpression

#is_scalar?

Constructor Details

#initialize(arg1, oper, arg2) ⇒ BinaryExpr

Returns a new instance of BinaryExpr.



157
158
159
160
161
162
163
# File 'lib/voruby/adql/adql.rb', line 157

def initialize(arg1, oper, arg2)
	super("#{arg1} #{oper} #{arg2}")

	self.arg1 = arg1
	self.arg2 = arg2
	self.oper = oper
end

Instance Attribute Details

#arg1Object

Returns the value of attribute arg1.



155
156
157
# File 'lib/voruby/adql/adql.rb', line 155

def arg1
  @arg1
end

#arg2Object

Returns the value of attribute arg2.



155
156
157
# File 'lib/voruby/adql/adql.rb', line 155

def arg2
  @arg2
end

#operObject

Returns the value of attribute oper.



155
156
157
# File 'lib/voruby/adql/adql.rb', line 155

def oper
  @oper
end

Class Method Details

.from_xml(node) ⇒ Object



199
200
201
202
203
204
205
# File 'lib/voruby/adql/adql.rb', line 199

def self.from_xml(node)
  oper = BinaryOperator.new(node.attributes['Oper'])
  arg1_node, arg2_node = node.elements.to_a('Arg')
  arg1 = ScalarExpression.from_xml(arg1_node)
  arg2 = ScalarExpression.from_xml(arg2_node)
  return BinaryExpr.new(arg1, oper, arg2)
end

Instance Method Details

#to_adqlsObject



26
27
28
# File 'lib/voruby/adql/transforms.rb', line 26

def to_adqls
	"#{self.arg1.to_adqls} #{self.oper.to_adqls} #{self.arg2.to_adqls}"
end

#to_sObject



195
196
197
# File 'lib/voruby/adql/adql.rb', line 195

def to_s
	"{arg1=#{self.arg1},oper=#{self.oper},arg2=#{self.arg2}}"
end