Class: Buezli::Api::Client::List
- Inherits:
-
Object
- Object
- Buezli::Api::Client::List
- Includes:
- Enumerable
- Defined in:
- lib/buezli/api/client/list.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(data:, meta:, client:, request_context:) ⇒ List
constructor
A new instance of List.
- #next_page ⇒ Object
- #pagination ⇒ Object
- #previous_page ⇒ Object
- #size ⇒ Object (also: #length)
Constructor Details
#initialize(data:, meta:, client:, request_context:) ⇒ List
Returns a new instance of List.
9 10 11 12 13 14 |
# File 'lib/buezli/api/client/list.rb', line 9 def initialize(data:, meta:, client:, request_context:) @data = data @meta = ( || {}).with_indifferent_access @client = client @request_context = request_context end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/buezli/api/client/list.rb', line 7 def data @data end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
7 8 9 |
# File 'lib/buezli/api/client/list.rb', line 7 def @meta end |
Instance Method Details
#[](index) ⇒ Object
30 31 32 |
# File 'lib/buezli/api/client/list.rb', line 30 def [](index) data[index] end |
#each(&block) ⇒ Object
16 17 18 |
# File 'lib/buezli/api/client/list.rb', line 16 def each(&block) data.each(&block) end |
#empty? ⇒ Boolean
20 21 22 |
# File 'lib/buezli/api/client/list.rb', line 20 def empty? data.empty? end |
#next_page ⇒ Object
38 39 40 |
# File 'lib/buezli/api/client/list.rb', line 38 def next_page request_page(pagination[:next]) end |
#pagination ⇒ Object
34 35 36 |
# File 'lib/buezli/api/client/list.rb', line 34 def pagination .fetch(:pagination, {}) end |
#previous_page ⇒ Object
42 43 44 |
# File 'lib/buezli/api/client/list.rb', line 42 def previous_page request_page(pagination[:prev]) end |
#size ⇒ Object Also known as: length
24 25 26 |
# File 'lib/buezli/api/client/list.rb', line 24 def size data.size end |