Class: TomatoPaste::Cli
- Inherits:
-
Object
- Object
- TomatoPaste::Cli
- Defined in:
- lib/tomato_paste/cli.rb
Instance Method Summary collapse
-
#ascii_banner ⇒ Object
Prints the colored “logo” of sorts “jgs” is the author of this awesome ascii tomato.
-
#initialize(input = $stdin, output = $stdout) ⇒ Cli
constructor
A new instance of Cli.
- #run ⇒ Object
-
#task_loop(big_break_duration = 1200) ⇒ Object
20 minutes.
Constructor Details
#initialize(input = $stdin, output = $stdout) ⇒ Cli
Returns a new instance of Cli.
11 12 13 14 15 |
# File 'lib/tomato_paste/cli.rb', line 11 def initialize(input = $stdin, output = $stdout) @input = input @output = output @vine = TomatoPaste::Vine.new end |
Instance Method Details
#ascii_banner ⇒ Object
Prints the colored “logo” of sorts “jgs” is the author of this awesome ascii tomato
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/tomato_paste/cli.rb', line 25 def = " | \n" += " __\\W/__ ".green.bold + "| _____ _ ____ _ \n" += " .'.-'|'-.'. ".red.bold + "| |_ _|__ _ __ ___ __ _| |_ ___ | _ \\ __ _ ___| |_ ___ \n" += "/ \\ ".red.bold + "| | |/ _ \\| '_ ` _ \\ / _` | __/ _ \\ | |_) / _` / __| __/ _ \\\n" += "| | ".red.bold + "| | | (_) | | | | | | (_| | || (_) | | __/ (_| \\__ \\ || __/\n" += " \\ / ".red.bold + "| |_|\\___/|_| |_| |_|\\__,_|\\__\\___/ |_| \\__,_|___/\\__\\___|\n" += " '-.___.-' ".red.bold + "| \n" += "jgs".yellow.bold + " | \n" += " ...a Pomodoro timer\n" end |
#run ⇒ Object
17 18 19 20 21 |
# File 'lib/tomato_paste/cli.rb', line 17 def run @output.print task_loop @output.print "\n\nBye!" end |
#task_loop(big_break_duration = 1200) ⇒ Object
20 minutes
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/tomato_paste/cli.rb', line 39 def task_loop(big_break_duration=1200) # 20 minutes begin @output.print "\n\n" @output.print "Task Description: " task_description = @input.gets.chomp @vine.add(TomatoPaste::Pomodoro.new(task_description)) @output.puts emit_notification "Starting Pomodoro ##{@vine.pomodori.count}" @vine.current_pomodoro.work_timer.start TomatoPaste::Notification.play_audio_alert if @vine.big_break_time? emit_notification "It's time for a big break. Come back in 20 minutes." Timer.new(big_break_duration).start else emit_notification "Pomodoro ##{@vine.pomodori.count} complete. Break starts now!" @vine.current_pomodoro.break_timer.start end TomatoPaste::Notification.play_audio_alert emit_notification "Break done!" @output.print "\nDo another Pomodoro? (Y/N): " end while @input.gets.upcase.chomp != "N" end |