Class: VORuby::ADQL::V1_0::ComparisonPred

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

Overview

Represents the Comparison of two expressions

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(arg1, comparison, arg2) ⇒ ComparisonPred

Returns a new instance of ComparisonPred.



1330
1331
1332
1333
1334
# File 'lib/voruby/adql/1.0/adql.rb', line 1330

def initialize(arg1, comparison, arg2)
  self.arg1 = arg1
  self.comparison = comparison
  self.arg2 = arg2
end

Instance Attribute Details

#arg1Object

Returns the value of attribute arg1.



1326
1327
1328
# File 'lib/voruby/adql/1.0/adql.rb', line 1326

def arg1
  @arg1
end

#arg2Object

Returns the value of attribute arg2.



1326
1327
1328
# File 'lib/voruby/adql/1.0/adql.rb', line 1326

def arg2
  @arg2
end

#comparisonObject

Returns the value of attribute comparison.



1326
1327
1328
# File 'lib/voruby/adql/1.0/adql.rb', line 1326

def comparison
  @comparison
end

Class Method Details

.from_xml(xml) ⇒ Object



1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
# File 'lib/voruby/adql/1.0/adql.rb', line 1378

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

.xml_typeObject



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

def self.xml_type; 'comparisonPredType' end

Instance Method Details

#==(p) ⇒ Object



1357
1358
1359
1360
1361
# File 'lib/voruby/adql/1.0/adql.rb', line 1357

def ==(p)
  self.arg1 == p.arg1 and
  self.comparison == p.comparison and
  self.arg2 == p.arg2
end

#to_sObject



1363
1364
1365
# File 'lib/voruby/adql/1.0/adql.rb', line 1363

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

#to_xml(name = nil) ⇒ Object



1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
# File 'lib/voruby/adql/1.0/adql.rb', line 1367

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