Class: CraftingTable::Search::SearchBuilder
- Inherits:
-
Object
- Object
- CraftingTable::Search::SearchBuilder
- Defined in:
- lib/crafting_table/search/search_builder.rb
Overview
A class which provides a basic API to construct searches.
This allows to easily create multiple searches without having to know about the underlying classes.
Instance Attribute Summary collapse
-
#case_sensitive ⇒ Boolean
Whether to search case-sensitively.
-
#damage_value ⇒ #include?, Fixnum
The damage value(s) for which to search.
-
#exact ⇒ Boolean
Whether to search for an exact match.
-
#input ⇒ Item
The input for which to search.
-
#item_id ⇒ #include?, Fixnum
The item ID(s) for which to search.
-
#name ⇒ String
The name for which to search.
-
#output ⇒ Item
The output for which to search.
Instance Method Summary collapse
-
#searches ⇒ Array<*Search>
Create a collection of searches based on the instance variables which were set.
Instance Attribute Details
#case_sensitive ⇒ Boolean
Returns Whether to search case-sensitively.
47 |
# File 'lib/crafting_table/search/search_builder.rb', line 47 attr_accessor :name, :exact, :case_sensitive |
#damage_value ⇒ #include?, Fixnum
Returns The damage value(s) for which to search.
47 |
# File 'lib/crafting_table/search/search_builder.rb', line 47 attr_accessor :name, :exact, :case_sensitive |
#exact ⇒ Boolean
Returns Whether to search for an exact match.
47 |
# File 'lib/crafting_table/search/search_builder.rb', line 47 attr_accessor :name, :exact, :case_sensitive |
#input ⇒ Item
Returns The input for which to search.
47 |
# File 'lib/crafting_table/search/search_builder.rb', line 47 attr_accessor :name, :exact, :case_sensitive |
#item_id ⇒ #include?, Fixnum
Returns The item ID(s) for which to search.
47 |
# File 'lib/crafting_table/search/search_builder.rb', line 47 attr_accessor :name, :exact, :case_sensitive |
#name ⇒ String
Returns The name for which to search.
47 48 49 |
# File 'lib/crafting_table/search/search_builder.rb', line 47 def name @name end |
#output ⇒ Item
Returns The output for which to search.
47 |
# File 'lib/crafting_table/search/search_builder.rb', line 47 attr_accessor :name, :exact, :case_sensitive |
Instance Method Details
#searches ⇒ Array<*Search>
Create a collection of searches based on the instance variables which were set.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/crafting_table/search/search_builder.rb', line 57 def searches searches = [] if name c_sens = case_sensitive.nil? ? true : case_sensitive if exact searches << NameSearch.new(name, case_sensitive: c_sens) else searches << FuzzyNameSearch.new(name, case_sensitive: c_sens) end end searches << DamageSearch.new(damage_value) if damage_value searches << ItemIDSearch.new(item_id) if item_id searches << InputSearch.new(input) if input searches << OutputSearch.new(output) if output searches end |