Class: VORuby::ADQL::UnionSearch
- Defined in:
- lib/voruby/adql/adql.rb,
lib/voruby/adql/transforms.rb
Overview
Represents expressions like A Or 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) ⇒ UnionSearch
constructor
A new instance of UnionSearch.
-
#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) ⇒ UnionSearch
Returns a new instance of UnionSearch.
1006 1007 1008 1009 |
# File 'lib/voruby/adql/adql.rb', line 1006 def initialize(cond1, cond2) self.cond1 = cond1 self.cond2 = cond2 end |
Instance Attribute Details
#cond1 ⇒ Object
Returns the value of attribute cond1.
1004 1005 1006 |
# File 'lib/voruby/adql/adql.rb', line 1004 def cond1 @cond1 end |
#cond2 ⇒ Object
Returns the value of attribute cond2.
1004 1005 1006 |
# File 'lib/voruby/adql/adql.rb', line 1004 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
1033 1034 1035 1036 1037 1038 1039 1040 |
# File 'lib/voruby/adql/adql.rb', line 1033 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.
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 |
# File 'lib/voruby/adql/adql.rb', line 1064 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.
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 |
# File 'lib/voruby/adql/adql.rb', line 1045 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
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 |
# File 'lib/voruby/adql/adql.rb', line 1083 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
239 240 241 |
# File 'lib/voruby/adql/transforms.rb', line 239 def to_adqls "#{self.cond1.to_adqls} OR #{self.cond2.to_adqls}" end |
#to_adqlx ⇒ Object
243 244 245 246 247 248 249 |
# File 'lib/voruby/adql/transforms.rb', line 243 def to_adqlx union_search = "<Condition xsi:type=\"unionSearchType\">\n" union_search << self.cond1.to_adqlx union_search << self.cond2.to_adqlx union_search << "</Condition>\n" return union_search end |
#to_s ⇒ Object
1021 1022 1023 |
# File 'lib/voruby/adql/adql.rb', line 1021 def to_s "{cond1=#{self.cond1},cond2=#{self.cond2}}" end |