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
-
#count_condition(attributes, times) ⇒ 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(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.
1013 1014 1015 1016 |
# File 'lib/voruby/adql/adql.rb', line 1013 def initialize(cond1, cond2) self.cond1 = cond1 self.cond2 = cond2 end |
Instance Attribute Details
#cond1 ⇒ Object
Returns the value of attribute cond1.
1011 1012 1013 |
# File 'lib/voruby/adql/adql.rb', line 1011 def cond1 @cond1 end |
#cond2 ⇒ Object
Returns the value of attribute cond2.
1011 1012 1013 |
# File 'lib/voruby/adql/adql.rb', line 1011 def cond2 @cond2 end |
Class Method Details
Instance Method Details
#count_condition(attributes, times) ⇒ Object
This method counts the number of times that a condition appears.
1109 1110 1111 1112 1113 |
# File 'lib/voruby/adql/adql.rb', line 1109 def count_condition(attributes, times) times = self.cond1.count_condition(attributes, times) times = self.cond2.count_condition(attributes, times) return times end |
#find_condition(type, attributes) ⇒ Object
This method finds a condition given its attributes and it returns it
1040 1041 1042 1043 1044 1045 1046 1047 |
# File 'lib/voruby/adql/adql.rb', line 1040 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.
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 |
# File 'lib/voruby/adql/adql.rb', line 1071 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.
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 |
# File 'lib/voruby/adql/adql.rb', line 1052 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
1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 |
# File 'lib/voruby/adql/adql.rb', line 1090 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
1028 1029 1030 |
# File 'lib/voruby/adql/adql.rb', line 1028 def to_s "{cond1=#{self.cond1},cond2=#{self.cond2}}" end |