Class: Pello::Actions::AddPomodoriToCard
- Inherits:
-
Object
- Object
- Pello::Actions::AddPomodoriToCard
- Defined in:
- lib/pello/actions/add_pomodori_to_card.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#prompt ⇒ Object
readonly
Returns the value of attribute prompt.
Instance Method Summary collapse
-
#initialize(prompt, logger = Pello::CardLogger.new) ⇒ AddPomodoriToCard
constructor
A new instance of AddPomodoriToCard.
- #run(user, board_url, list_name) ⇒ Object
Constructor Details
#initialize(prompt, logger = Pello::CardLogger.new) ⇒ AddPomodoriToCard
Returns a new instance of AddPomodoriToCard.
8 9 10 11 |
# File 'lib/pello/actions/add_pomodori_to_card.rb', line 8 def initialize(prompt, logger = Pello::CardLogger.new) @prompt = prompt @logger = logger end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/pello/actions/add_pomodori_to_card.rb', line 6 def logger @logger end |
#prompt ⇒ Object (readonly)
Returns the value of attribute prompt.
6 7 8 |
# File 'lib/pello/actions/add_pomodori_to_card.rb', line 6 def prompt @prompt end |
Instance Method Details
#run(user, board_url, list_name) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/pello/actions/add_pomodori_to_card.rb', line 13 def run(user, board_url, list_name) board = Pello::Inputs.choose_board user, board_url return unless board puts board.as_table continue = true while continue list = Pello::Inputs.choose_list board, list_name return unless list card = Pello::Inputs.choose_card list next unless card pomodori_before = card.extract_pomodori pomodori_to_add = prompt.ask('Pomodori', default: 1) new_name = name_with_added_pomodori(card, pomodori_to_add.to_i) puts "Updating card #{card.name}" puts "New title: #{new_name}" if prompt.yes?('Confirm?') card.name = new_name card.save logger.log user, card, "[#{Time.now}] #{card.extract_name} (#{pomodori_before} -> #{card.extract_pomodori})" puts('Done!') else puts 'Ok, bye!' nil end continue = prompt.yes?('Another one?') end end |