Class: VORuby::ADQL::Where
- Defined in:
- lib/voruby/adql/adql.rb,
lib/voruby/adql/transforms.rb
Overview
Represents the Where part of the query.
Instance Attribute Summary collapse
-
#condition ⇒ Object
Returns the value of attribute condition.
Class Method Summary collapse
Instance Method Summary collapse
-
#count_condition(attributes) ⇒ Object
This method counts the number of times that a condition appears.
-
#find_condition(type, attributes) ⇒ Object
This method finds a condition given its attributes and it returns it.
-
#initialize(condition) ⇒ Where
constructor
A new instance of Where.
-
#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.
-
#remove_condition(type, attributes) ⇒ Object
This method removes a condition.
-
#replace_condition(type, attributes, new_condition) ⇒ Object
This method replaces a condition for a new condition.
- #to_adqls ⇒ Object
- #to_adqlx ⇒ Object
- #to_s ⇒ Object
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
#condition ⇒ Object
Returns the value of attribute condition.
2071 2072 2073 |
# File 'lib/voruby/adql/adql.rb', line 2071 def condition @condition end |
Class Method Details
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_adqls ⇒ Object
392 393 394 |
# File 'lib/voruby/adql/transforms.rb', line 392 def to_adqls "WHERE #{self.condition.to_adqls}" if self.condition end |
#to_adqlx ⇒ Object
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_s ⇒ Object
2082 2083 2084 |
# File 'lib/voruby/adql/adql.rb', line 2082 def to_s "{condition=#{self.condition}}" end |