class CraftingTable::Search::InputSearch

A class which allows to filter recipes by their input.

@author Michael Senn <morrolan@morrolan.ch> @since 0.3

Attributes

item[R]

Public Class Methods

new(item) click to toggle source

Create a new InputSearch

@param [Item] item Item for which to filter.

# File lib/crafting_table/search/input_search.rb, line 17
def initialize(item)
  @item = item
end

Public Instance Methods

==(other) click to toggle source

Compare two searches for equality.

They are considered equal if the item for which they filter is equal.

@param [InputSearch] other InputSearch which to compare for equality. @return [Boolean] Whether two searches are equal.

# File lib/crafting_table/search/input_search.rb, line 37
def ==(other)
  other.item == item
end
Also aliased as: eq?
apply_to(recipes) click to toggle source

Apply this filter to a collection of recipes.

@param [Array<Recipe>] recipes

Collection of recipes which to filter.

@return [Array<Recipe>]

Recipes which matched the search criteria
# File lib/crafting_table/search/input_search.rb, line 27
def apply_to(recipes)
  recipes.select { |recipe| recipe.input.include? item }
end
eq?(other)
Alias for: ==