Class: RallyUp::ListObject
- Inherits:
-
Object
- Object
- RallyUp::ListObject
- Defined in:
- lib/rally_up/list_object.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#has_next_page ⇒ Object
readonly
Returns the value of attribute has_next_page.
-
#has_previous_page ⇒ Object
readonly
Returns the value of attribute has_previous_page.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#json ⇒ Object
readonly
Returns the value of attribute json.
-
#page_index ⇒ Object
readonly
Returns the value of attribute page_index.
-
#page_size ⇒ Object
readonly
Returns the value of attribute page_size.
-
#total_count ⇒ Object
readonly
Returns the value of attribute total_count.
-
#total_pages ⇒ Object
readonly
Returns the value of attribute total_pages.
Instance Method Summary collapse
-
#initialize(json_response, klass) ⇒ ListObject
constructor
A new instance of ListObject.
Constructor Details
#initialize(json_response, klass) ⇒ ListObject
Returns a new instance of ListObject.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rally_up/list_object.rb', line 8 def initialize(json_response, klass) @json = json_response if klass @items = json.dig(:Result, :Items).to_a.map do |data| klass.new(data) end end @count = json_response.dig(:Result, :Count) @page_index = json_response.dig(:Result, :PageIndex) @page_size = json_response.dig(:Result, :PageSize) @total_count = json_response.dig(:Result, :TotalCount) @total_pages = json_response.dig(:Result, :TotalPages) @has_previous_page = json_response.dig(:Result, :HasPreviousPage) @has_next_page = json_response.dig(:Result, :HasNextPage) end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
5 6 7 |
# File 'lib/rally_up/list_object.rb', line 5 def count @count end |
#has_next_page ⇒ Object (readonly)
Returns the value of attribute has_next_page.
5 6 7 |
# File 'lib/rally_up/list_object.rb', line 5 def has_next_page @has_next_page end |
#has_previous_page ⇒ Object (readonly)
Returns the value of attribute has_previous_page.
5 6 7 |
# File 'lib/rally_up/list_object.rb', line 5 def has_previous_page @has_previous_page end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
5 6 7 |
# File 'lib/rally_up/list_object.rb', line 5 def items @items end |
#json ⇒ Object (readonly)
Returns the value of attribute json.
5 6 7 |
# File 'lib/rally_up/list_object.rb', line 5 def json @json end |
#page_index ⇒ Object (readonly)
Returns the value of attribute page_index.
5 6 7 |
# File 'lib/rally_up/list_object.rb', line 5 def page_index @page_index end |
#page_size ⇒ Object (readonly)
Returns the value of attribute page_size.
5 6 7 |
# File 'lib/rally_up/list_object.rb', line 5 def page_size @page_size end |
#total_count ⇒ Object (readonly)
Returns the value of attribute total_count.
5 6 7 |
# File 'lib/rally_up/list_object.rb', line 5 def total_count @total_count end |
#total_pages ⇒ Object (readonly)
Returns the value of attribute total_pages.
5 6 7 |
# File 'lib/rally_up/list_object.rb', line 5 def total_pages @total_pages end |