Class: Ifin24::Commands::ListEntries

Inherits:
Base
  • Object
show all
Defined in:
lib/ifin24/commands/list_entries.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Helpers::Printer

#print_list

Constructor Details

This class inherits a constructor from Ifin24::Commands::Base

Instance Method Details

#executeObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ifin24/commands/list_entries.rb', line 5

def execute
  current_page = 1
  list, pages = @client.fetch_entries(current_page)
  print_entries(list)

  catch :exit do
    loop do
      choose do |menu|
        menu.index = :letter
        menu.index_suffix = ") "

        menu.choice("Poprzednia strona") do
          current_page -= 1 if current_page > 1

          list, pages = @client.fetch_entries(current_page)
          print_entries(list)
        end

        menu.choice("Następna strona") do
          current_page += 1 if current_page < pages

          list, pages = @client.fetch_entries(current_page)
          print_entries(list)
        end

        menu.choice("Powrót do głównego menu") { throw :exit }
      end
    end
  end
end