Class: Ifin24::Commands::AddExpense

Inherits:
Base
  • Object
show all
Defined in:
lib/ifin24/commands/add_expense.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/add_expense.rb', line 5

def execute
  entry = get_entry

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

        menu.choice("Nazwa: #{entry.title}") { get_title(entry) }
        menu.choice("Data: #{entry.date}") { get_date(entry) }
        menu.choice("Konto: #{entry.account.name}") { (entry) }
        menu.choice("Kategoria: #{entry.category_full_name}") { get_category(entry) }
        menu.choice("Kwota: #{entry.amount}") { get_amount(entry) }
        menu.choice("Tagi: #{entry.tags}") { get_tags(entry) }
        menu.choice("Opis: #{entry.note}") { get_note(entry) }

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

        menu.choice("Wyślij") do
          puts "Wysyłanie danych..."
          @client.send_entry(entry)
          throw :all_ok
        end
      end
    end
  end
end