Class: FreshBooks::ListProxy
- Inherits:
-
Object
- Object
- FreshBooks::ListProxy
- Includes:
- Enumerable
- Defined in:
- lib/freshbooks/list_proxy.rb
Instance Method Summary collapse
- #[](position) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(list_page_proc) ⇒ ListProxy
constructor
A new instance of ListProxy.
- #size ⇒ Object
Constructor Details
#initialize(list_page_proc) ⇒ ListProxy
Returns a new instance of ListProxy.
5 6 7 8 |
# File 'lib/freshbooks/list_proxy.rb', line 5 def initialize(list_page_proc) @list_page_proc = list_page_proc move_to_page(1) end |
Instance Method Details
#[](position) ⇒ Object
18 19 20 21 |
# File 'lib/freshbooks/list_proxy.rb', line 18 def [](position) move_to_page(@current_page.page_number(position)) @array[@current_page.position_number(position)] end |
#each(&block) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/freshbooks/list_proxy.rb', line 10 def each(&block) move_to_page(1) begin @array.each(&block) end while @current_page.next_page? && next_page end |
#size ⇒ Object
23 24 25 |
# File 'lib/freshbooks/list_proxy.rb', line 23 def size @current_page.total end |