Class: Unsplash::SearchResult
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Unsplash::SearchResult
- Defined in:
- lib/unsplash/search.rb
Overview
Decorates Array of klass-type objects with total and total_pages attributes
Instance Attribute Summary collapse
-
#total ⇒ Object
readonly
Returns the value of attribute total.
-
#total_pages ⇒ Object
readonly
Returns the value of attribute total_pages.
Instance Method Summary collapse
-
#initialize(decorated, klass) ⇒ SearchResult
constructor
A new instance of SearchResult.
Constructor Details
#initialize(decorated, klass) ⇒ SearchResult
Returns a new instance of SearchResult.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/unsplash/search.rb', line 7 def initialize(decorated, klass) @total = decorated["total"] @total_pages = decorated["total_pages"] list = decorated["results"].map do |content| klass.new content.to_hash end super(list) end |
Instance Attribute Details
#total ⇒ Object (readonly)
Returns the value of attribute total.
5 6 7 |
# File 'lib/unsplash/search.rb', line 5 def total @total end |
#total_pages ⇒ Object (readonly)
Returns the value of attribute total_pages.
5 6 7 |
# File 'lib/unsplash/search.rb', line 5 def total_pages @total_pages end |