Class: Yuriita::SearchFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/yuriita/search_filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input:, combination:, &block) ⇒ SearchFilter

Returns a new instance of SearchFilter.



5
6
7
8
9
# File 'lib/yuriita/search_filter.rb', line 5

def initialize(input:, combination:, &block)
  @input = input
  @combination = combination
  @block = block
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



3
4
5
# File 'lib/yuriita/search_filter.rb', line 3

def input
  @input
end

Instance Method Details

#apply(relation, keywords) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/yuriita/search_filter.rb', line 11

def apply(relation, keywords)
  relations = keywords.map do |keyword|
    block.call(relation, keyword.to_s)
  end

  combination.new(
    base_relation: relation,
    relations: relations,
  ).combine
end