Class: VORuby::ADQL::Where

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

Overview

Represents the Where part of the query.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(condition) ⇒ Where

Returns a new instance of Where.



2073
2074
2075
# File 'lib/voruby/adql/adql.rb', line 2073

def initialize(condition)
  self.condition = condition
end

Instance Attribute Details

#conditionObject

Returns the value of attribute condition.



2071
2072
2073
# File 'lib/voruby/adql/adql.rb', line 2071

def condition
  @condition
end

Class Method Details

.from_xml(node) ⇒ Object



2086
2087
2088
2089
2090
# File 'lib/voruby/adql/adql.rb', line 2086

def self.from_xml(node)
  cond_node = REXML::XPath.first(node, 'Condition')
  cond = Condition.from_xml(cond_node)
  return Where.new(cond)
end

Instance Method Details

#count_condition(attributes) ⇒ Object

This method counts the number of times that a condition appears.



2133
2134
2135
2136
# File 'lib/voruby/adql/adql.rb', line 2133

def count_condition(attributes)
  times = 0
  return self.condition.count_condition(attributes, times)
end

#find_condition(type, attributes) ⇒ Object

This method finds a condition given its attributes and it returns it



2093
2094
2095
# File 'lib/voruby/adql/adql.rb', line 2093

def find_condition(type, attributes)
  return self.condition.find_condition(type, attributes)
end

#modify_condition(type, attributes_old, attributes_new) ⇒ Object

This method modify a condition given its old attributtes, replacing the old attributes with the new attributes.



2113
2114
2115
# File 'lib/voruby/adql/adql.rb', line 2113

def modify_condition(type, attributes_old, attributes_new)
  self.condition = self.condition.modify_condition(type, attributes_old, attributes_new)
end

#remove_condition(type, attributes) ⇒ Object

This method removes a condition. -1 means that the condition must be removed. 1 means that the condition given its attributes wasn’t found. The other case is that the condition was changed in another place, for example could have been removed in the intersectionSearchType called.



2102
2103
2104
2105
2106
2107
2108
2109
# File 'lib/voruby/adql/adql.rb', line 2102

def remove_condition(type, attributes)
  condition = self.condition.remove_condition(type, attributes)
  if condition == -1
    self.condition = nil
  elsif condition != 1
    self.condition = condition
  end
end

#replace_condition(type, attributes, new_condition) ⇒ Object

This method replaces a condition for a new condition. -1 means that the condition must be replaced. 1 means that the old condition in this case wasn’t found so that the old condition won’t be replaced. The other case is that the condition was changed in another place, for example could have been replaced in the intersectionSearchType called.



2123
2124
2125
2126
2127
2128
2129
2130
# File 'lib/voruby/adql/adql.rb', line 2123

def replace_condition(type, attributes, new_condition)
  condition = self.condition.replace_condition(type, attributes, new_condition)
  if condition == -1
    self.condition = new_condition
  elsif condition != 1
    self.condition = condition
  end
end

#to_adqlsObject



392
393
394
# File 'lib/voruby/adql/transforms.rb', line 392

def to_adqls
  "WHERE #{self.condition.to_adqls}" if self.condition
end

#to_adqlxObject



396
397
398
399
400
401
402
403
# File 'lib/voruby/adql/transforms.rb', line 396

def to_adqlx
  if self.condition
    where = "<Where>\n"
    where << self.condition.to_adqlx
    where << "\n</Where>\n"
    return where
  end
end

#to_sObject



2082
2083
2084
# File 'lib/voruby/adql/adql.rb', line 2082

def to_s
  "{condition=#{self.condition}}"
end