Class: VORuby::ADQL::IntersectionSearch
- Defined in:
- lib/voruby/adql/adql.rb,
lib/voruby/adql/transforms.rb
Overview
Represents expressions like a AND b.
Instance Attribute Summary collapse
-
#cond1 ⇒ Object
Returns the value of attribute cond1.
-
#cond2 ⇒ Object
Returns the value of attribute cond2.
Class Method Summary collapse
Instance Method Summary collapse
-
#find_condition(type, attributes) ⇒ Object
This method finds a condition given its attributes and it returns it.
-
#initialize(cond1, cond2) ⇒ IntersectionSearch
constructor
A new instance of IntersectionSearch.
-
#modify_condition(type, attributes_old, attributes_new) ⇒ Object
This method modifies a condition given its old attributes, 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(cond1, cond2) ⇒ IntersectionSearch
Returns a new instance of IntersectionSearch.
906 907 908 909 |
# File 'lib/voruby/adql/adql.rb', line 906 def initialize(cond1, cond2) self.cond1 = cond1 self.cond2 = cond2 end |
Instance Attribute Details
#cond1 ⇒ Object
Returns the value of attribute cond1.
904 905 906 |
# File 'lib/voruby/adql/adql.rb', line 904 def cond1 @cond1 end |
#cond2 ⇒ Object
Returns the value of attribute cond2.
904 905 906 |
# File 'lib/voruby/adql/adql.rb', line 904 def cond2 @cond2 end |
Class Method Details
Instance Method Details
#find_condition(type, attributes) ⇒ Object
This method finds a condition given its attributes and it returns it
933 934 935 936 937 938 939 940 |
# File 'lib/voruby/adql/adql.rb', line 933 def find_condition(type, attributes) condition = self.cond1.find_condition(type, attributes) if condition == nil condition = self.cond2.find_condition(type, attributes) end return condition end |
#modify_condition(type, attributes_old, attributes_new) ⇒ Object
This method modifies a condition given its old attributes, replacing the old attributes with the new attributes.
964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 |
# File 'lib/voruby/adql/adql.rb', line 964 def modify_condition(type, attributes_old, attributes_new) cond1 = self.cond1.modify_condition(type, attributes_old, attributes_new) if cond1 != nil self.cond1 = cond1 else cond2 = self.cond2.modify_condition(type, attributes_old, attributes_new) if cond2 != nil self.cond2 = cond2 else return nil end end return self 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, so that the process must continue.
945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 |
# File 'lib/voruby/adql/adql.rb', line 945 def remove_condition(type, attributes) cond1 = self.cond1.remove_condition(type, attributes) if cond1 == -1 return self.cond2 elsif cond1 == 1 cond2 = self.cond2.remove_condition(type, attributes) if cond2 == -1 return self.cond1 elsif cond2 == 1 return 1 end else self.cond1 = cond1 return self 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 for the new condition. 1 means that the process must continue.
983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 |
# File 'lib/voruby/adql/adql.rb', line 983 def replace_condition(type, attributes, new_condition) cond1 = self.cond1.replace_condition(type, attributes, new_condition) if cond1 == -1 self.cond1 = new_condition return self elsif cond1 == 1 cond2 = self.cond2.replace_condition(type, attributes, new_condition) if cond2 == -1 self.cond2 = new_condition return self elsif cond2 == 1 return 1 end else return self end end |
#to_adqls ⇒ Object
225 226 227 |
# File 'lib/voruby/adql/transforms.rb', line 225 def to_adqls "#{self.cond1.to_adqls} AND #{self.cond2.to_adqls}" end |
#to_adqlx ⇒ Object
229 230 231 232 233 234 235 |
# File 'lib/voruby/adql/transforms.rb', line 229 def to_adqlx intersection_search = "<Condition xsi:type=\"intersectionSearchType\">\n" intersection_search << self.cond1.to_adqlx intersection_search << self.cond2.to_adqlx intersection_search << "</Condition>\n" return intersection_search end |
#to_s ⇒ Object
921 922 923 |
# File 'lib/voruby/adql/adql.rb', line 921 def to_s "{cond1=#{self.cond1},cond2=#{self.cond2}}" end |