Class: RallyUp::ListObject

Inherits:
Object
  • Object
show all
Defined in:
lib/rally_up/list_object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#countObject (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_pageObject (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_pageObject (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

#itemsObject (readonly)

Returns the value of attribute items.



5
6
7
# File 'lib/rally_up/list_object.rb', line 5

def items
  @items
end

#jsonObject (readonly)

Returns the value of attribute json.



5
6
7
# File 'lib/rally_up/list_object.rb', line 5

def json
  @json
end

#page_indexObject (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_sizeObject (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_countObject (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_pagesObject (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