Class: Lospec::Palette::Search
- Inherits:
-
Object
- Object
- Lospec::Palette::Search
- Defined in:
- lib/lospec/palette/search.rb
Constant Summary collapse
- SORT_TYPES =
%i[default alphabetical downloads newest].freeze
Instance Attribute Summary collapse
-
#colors ⇒ Object
readonly
Returns the value of attribute colors.
-
#sort ⇒ Object
readonly
Returns the value of attribute sort.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
-
#initialize(colors: nil, tag: "", sort: :default) ⇒ Search
constructor
A new instance of Search.
- #results ⇒ Object
Constructor Details
#initialize(colors: nil, tag: "", sort: :default) ⇒ Search
Returns a new instance of Search.
13 14 15 16 17 18 19 |
# File 'lib/lospec/palette/search.rb', line 13 def initialize(colors: nil, tag: "", sort: :default) fail ArgumentError, "Sort should be one of #{SORT_TYPES}" unless SORT_TYPES.include?(sort.to_sym) @colors = colors @tag = tag @sort = sort end |
Instance Attribute Details
#colors ⇒ Object (readonly)
Returns the value of attribute colors.
11 12 13 |
# File 'lib/lospec/palette/search.rb', line 11 def colors @colors end |
#sort ⇒ Object (readonly)
Returns the value of attribute sort.
11 12 13 |
# File 'lib/lospec/palette/search.rb', line 11 def sort @sort end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
11 12 13 |
# File 'lib/lospec/palette/search.rb', line 11 def tag @tag end |
Instance Method Details
#results ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/lospec/palette/search.rb', line 21 def results(&) return to_enum(:results).lazy unless block_given? (0..).lazy.each do |page| # : Numeric results = results_for_page(page:) results.each(&) break if results.empty? end end |