class Aquarium::Finders::FinderResult

FinderResult

Wraps hashes that hold the results of various *Finder utilities. The not_matched method returns specified inputs that did not result in a successful find.

Constants

NIL_OBJECT

Attributes

matched[RW]
not_matched[RW]

Public Class Methods

new(hash = {}) click to toggle source
   # File lib/aquarium/finders/finder_result.rb
31 def initialize hash = {}
32   @matched = convert_hash_values_to_sets(hash.reject {|key, value| key.eql?(:not_matched)})
33   @not_matched = convert_hash_values_to_sets(make_hash(hash[:not_matched]) {|x| Set.new} || {})
34 end

Public Instance Methods

&(other_result)
Alias for: and
-(other_result)
Alias for: minus
<<(other_result) click to toggle source
   # File lib/aquarium/finders/finder_result.rb
48 def << other_result
49   append_matched     other_result.matched
50   append_not_matched other_result.not_matched
51   self
52 end
==(other)
Alias for: eql?
and(other_result) click to toggle source

“And” two results together

   # File lib/aquarium/finders/finder_result.rb
70 def and other_result
71   result = dup
72   result.matched     = hash_intersection(matched,     other_result.matched)
73   result.not_matched = hash_intersection(not_matched, other_result.not_matched)
74   result
75 end
Also aliased as: intersection, &
append_matched(other_hash = {}) click to toggle source
   # File lib/aquarium/finders/finder_result.rb
89 def append_matched other_hash = {}
90   @matched = convert_hash_values_to_sets hash_union(matched, other_hash)
91 end
append_not_matched(other_hash = {}) click to toggle source
   # File lib/aquarium/finders/finder_result.rb
93 def append_not_matched other_hash = {}
94   @not_matched = convert_hash_values_to_sets hash_union(not_matched, other_hash)
95   @not_matched.each_key {|key| purge_matched key}
96 end
empty?() click to toggle source

Were there no matches?

    # File lib/aquarium/finders/finder_result.rb
112 def empty?
113   matched.empty?
114 end
eql?(other) click to toggle source
    # File lib/aquarium/finders/finder_result.rb
 98 def eql? other
 99   object_id == other.object_id ||
100   (matched == other.matched and not_matched == other.not_matched)
101 end
Also aliased as: ==
inspect() click to toggle source
    # File lib/aquarium/finders/finder_result.rb
105 def inspect 
106   "FinderResult: {matched: #{matched.inspect}, not_matched: #{not_matched.inspect}}"
107 end
Also aliased as: to_s
intersection(other_result)
Alias for: and
matched_keys() click to toggle source

Convenience method to get the keys for the matches.

   # File lib/aquarium/finders/finder_result.rb
39 def matched_keys
40   @matched.keys
41 end
minus(other_result) click to toggle source
   # File lib/aquarium/finders/finder_result.rb
80 def minus other_result
81   result = dup
82   result.matched     = matched     - other_result.matched
83   result.not_matched = not_matched - other_result.not_matched
84   result
85 end
Also aliased as: -
not_matched_keys() click to toggle source

Convenience method to get the keys for the items that did not result in matches.

   # File lib/aquarium/finders/finder_result.rb
44 def not_matched_keys
45   @not_matched.keys
46 end
or(other_result) click to toggle source

“Or” two results together

   # File lib/aquarium/finders/finder_result.rb
59 def or other_result
60   result = dup
61   result.matched     = hash_union(matched,     other_result.matched)
62   result.not_matched = hash_union(not_matched, other_result.not_matched)
63   result
64 end
Also aliased as: union, |
to_s()
Alias for: inspect
union(other_result)
Alias for: or
|(other_result)
Alias for: or