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.



2027
2028
2029
# File 'lib/voruby/adql/adql.rb', line 2027

def initialize(condition)
  self.condition = condition
end

Instance Attribute Details

#conditionObject

Returns the value of attribute condition.



2025
2026
2027
# File 'lib/voruby/adql/adql.rb', line 2025

def condition
  @condition
end

Class Method Details

.from_xml(node) ⇒ Object



2040
2041
2042
2043
2044
# File 'lib/voruby/adql/adql.rb', line 2040

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

#find_condition(type, attributes) ⇒ Object

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



2047
2048
2049
# File 'lib/voruby/adql/adql.rb', line 2047

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.



2067
2068
2069
# File 'lib/voruby/adql/adql.rb', line 2067

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.



2056
2057
2058
2059
2060
2061
2062
2063
# File 'lib/voruby/adql/adql.rb', line 2056

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.



2077
2078
2079
2080
2081
2082
2083
2084
# File 'lib/voruby/adql/adql.rb', line 2077

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



2036
2037
2038
# File 'lib/voruby/adql/adql.rb', line 2036

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