Class: INatGet::Data::DSL::Condition::AND
#manager
#!, #api_query, #sequel_query, #|
#AND, #ANYTHING, #NOT, #NOTHING, #OR, #Q, #finish_time, #get_identification, #get_observation, #get_place, #get_project, #get_taxon, #get_user, #now, #select_identifications, #select_observations, #select_places, #select_projects, #select_taxa, #select_users, #start_time, #time_range, #today, #version, #version!, #version?, #version_alias
Instance Attribute Details
#model ⇒ class of Sequel::Model
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
21
22
23
|
# File 'lib/inat-get/data/dsl/conditions/and.rb', line 21
def model
@operands.map(&:model).find { |h| !h.nil? }
end
|
#operands ⇒ Array<Condition>
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
11
12
13
|
# File 'lib/inat-get/data/dsl/conditions/and.rb', line 11
def operands
@operands
end
|
Class Method Details
52
53
54
55
56
57
58
59
|
# File 'lib/inat-get/data/dsl/conditions/and.rb', line 52
def [] *operands
return INatGet::Data::DSL::ANYTHING if operands.empty?
return INatGet::Data::DSL::NOTHING if operands.include?(INatGet::Data::DSL::NOTHING)
operands.delete INatGet::Data::DSL::ANYTHING
operands.uniq!
return operands.first if operands.size == 1
new(*operands).freeze
end
|
Instance Method Details
30
31
32
33
34
35
36
|
# File 'lib/inat-get/data/dsl/conditions/and.rb', line 30
def & other
if other.is_a?(AND)
AND[ *self.operands, *other.operands ]
else
AND[ *self.operands, other ]
end
end
|
#==(other) ⇒ Boolean
39
40
41
42
43
|
# File 'lib/inat-get/data/dsl/conditions/and.rb', line 39
def == other
return true if self.equal?(other)
return false unless other.is_a?(AND)
self.operands.all? { |o| other.operands.include?(o) } && other.operands.all? { |o| self.operands.include?(o) }
end
|
#and_merge_sets(left, right) ⇒ Object
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/inat-get/data/dsl/conditions/and.rb', line 162
def and_merge_sets left, right
sample = left.first
return ::Set[] if sample.nil?
return left & right unless sample.is_a?(INatGet::Data::Model::Taxon)
result = ::Set[]
left.each do |value|
result << value if right.any? { |v| v === value }
end
right.each do |value|
result << value if left.any? { |v| v === value }
end
INatGet::Data::Model::Taxon::compact_set(*result)
end
|