class PMS::Proxy
Attributes
index[R]
pms[R]
results[R]
Public Class Methods
new(pms)
click to toggle source
# File lib/pms/proxy.rb, line 33 def initialize(pms) @pms = pms @index = pms.index @results = pms.results end
Public Instance Methods
matches()
click to toggle source
# File lib/pms/proxy.rb, line 39 def matches index.matches(results) end
Private Instance Methods
apply_operator(op, doc_nums)
click to toggle source
# File lib/pms/proxy.rb, line 78 def apply_operator(op, doc_nums) results = self.results case op = op.to_s.downcase when 'and' then results &= doc_nums when 'or' then results |= doc_nums when 'not' then results -= doc_nums else raise ArgumentError, "invalid operator `#{op}'" end clone_with_results(results) # allow chaining! end
apply_operator_with_block(op) { |pms| ... }
click to toggle source
# File lib/pms/proxy.rb, line 71 def apply_operator_with_block(op) case sub = yield(pms) when Proxy then apply_operator(op, sub.results) else raise "sub-query must return a #{Proxy} object (got #{sub.class})" end end
apply_operator_with_token(op, token)
click to toggle source
# File lib/pms/proxy.rb, line 67 def apply_operator_with_token(op, token) apply_operator(op, index.results(token)) end
clone_with_results(results)
click to toggle source
# File lib/pms/proxy.rb, line 91 def clone_with_results(results) clone.tap { |clone| clone.instance_variable_set(:@results, results) } end