Class: HelloSign::Resource::ResourceArray

Inherits:
Array
  • Object
show all
Defined in:
lib/hello_sign/resource/resource_array.rb

Overview

Stores an array of HelloSign BaseResource with paging information

Author:

  • hellosign

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash, key, resource_class) ⇒ type

create a new ResourceArray from a hash

Parameters:

  • hash (Hash)

    data of the array

  • key (String)

    key of the hash, point to where resource array data is

  • resource_class (Class)

    a Resource Class object inherited from BaseResource. Use the created array item from hash



20
21
22
23
24
25
26
27
28
# File 'lib/hello_sign/resource/resource_array.rb', line 20

def initialize(hash, key, resource_class)
  @page = hash['list_info']['page']
  @num_pages = hash['list_info']['num_pages']
  @num_results = hash['list_info']['num_results']
  @page_size = hash['list_info']['page_size']
  hash[key] && hash[key].each do |resouce|
    self << resource_class.new(resouce, nil)
  end
end

Instance Attribute Details

#num_pagesObject (readonly)

Returns the value of attribute num_pages.



10
11
12
# File 'lib/hello_sign/resource/resource_array.rb', line 10

def num_pages
  @num_pages
end

#num_resultsObject (readonly)

Returns the value of attribute num_results.



10
11
12
# File 'lib/hello_sign/resource/resource_array.rb', line 10

def num_results
  @num_results
end

#pageObject (readonly)

Returns the value of attribute page.



10
11
12
# File 'lib/hello_sign/resource/resource_array.rb', line 10

def page
  @page
end

#page_sizeObject (readonly)

Returns the value of attribute page_size.



10
11
12
# File 'lib/hello_sign/resource/resource_array.rb', line 10

def page_size
  @page_size
end