Class: VORuby::ADQL::V1_0::BinaryExpr

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

Overview

Represents a binary expression such as a+b

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(arg1, oper, arg2) ⇒ BinaryExpr

Returns a new instance of BinaryExpr.



79
80
81
82
83
84
# File 'lib/voruby/adql/1.0/adql.rb', line 79

def initialize(arg1, oper, arg2)
  super()
  self.arg1 = arg1
  self.oper = oper
  self.arg2 = arg2
end

Instance Attribute Details

#arg1Object

Returns the value of attribute arg1.



75
76
77
# File 'lib/voruby/adql/1.0/adql.rb', line 75

def arg1
  @arg1
end

#arg2Object

Returns the value of attribute arg2.



75
76
77
# File 'lib/voruby/adql/1.0/adql.rb', line 75

def arg2
  @arg2
end

#operObject

Returns the value of attribute oper.



75
76
77
# File 'lib/voruby/adql/1.0/adql.rb', line 75

def oper
  @oper
end

Class Method Details

.from_xml(xml) ⇒ Object



128
129
130
131
132
133
134
135
136
137
# File 'lib/voruby/adql/1.0/adql.rb', line 128

def self.from_xml(xml)
  root = element_from(xml)
  
  args = REXML::XPath.match(root, 'x:Arg', {'x' => obj_ns.uri}).collect{ |a| xml_to_obj(a) }
  self.new(
    args[0],
    BinaryOperator.new(root.attributes.get_attribute_ns(obj_ns.uri, 'Oper').value),
    args[1]
  )
end

.xml_typeObject



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

def self.xml_type; 'binaryExprType' end

Instance Method Details

#==(e) ⇒ Object



122
123
124
125
126
# File 'lib/voruby/adql/1.0/adql.rb', line 122

def ==(e)
  self.arg1 == e.arg1 and
  self.oper == e.oper and
  self.arg2 == e.arg2
end

#to_sObject



107
108
109
# File 'lib/voruby/adql/1.0/adql.rb', line 107

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

#to_xml(name = nil) ⇒ Object



111
112
113
114
115
116
117
118
119
120
# File 'lib/voruby/adql/1.0/adql.rb', line 111

def to_xml(name=nil)
  el = super(name)
  
  el.attributes["#{obj_ns.prefix}:Oper"] = self.oper.to_s
  el.add_element(self.arg1.to_xml('Arg'))
  el.add_element(self.arg2.to_xml('Arg'))
  
  collapse_namespaces(el)
  el
end