Class: CraftingTable::Search::OutputSearch
- Inherits:
-
Object
- Object
- CraftingTable::Search::OutputSearch
- Defined in:
- lib/crafting_table/search/output_search.rb
Overview
A class which allows to filter recipes by their output.
Instance Attribute Summary collapse
- #item ⇒ Object readonly
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eq?)
Compare two searches for equality.
-
#apply_to(recipes) ⇒ Array<Recipe>
Apply this filter to a collection of recipes.
-
#initialize(item) ⇒ OutputSearch
constructor
Create a new OutputSearch.
Constructor Details
#initialize(item) ⇒ OutputSearch
Create a new OutputSearch.
17 18 19 |
# File 'lib/crafting_table/search/output_search.rb', line 17 def initialize(item) @item = item end |
Instance Attribute Details
#item ⇒ Object (readonly)
12 13 14 |
# File 'lib/crafting_table/search/output_search.rb', line 12 def item @item end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eq?
Compare two searches for equality.
They are considered equal if the item for which they filter is equal.
37 38 39 |
# File 'lib/crafting_table/search/output_search.rb', line 37 def ==(other) other.item == item end |
#apply_to(recipes) ⇒ Array<Recipe>
Apply this filter to a collection of recipes.
27 28 29 |
# File 'lib/crafting_table/search/output_search.rb', line 27 def apply_to(recipes) recipes.select { |recipe| recipe.output.include? item } end |