Class: TerminalCalendar::Selection::MonthYearDialog
- Inherits:
-
Object
- Object
- TerminalCalendar::Selection::MonthYearDialog
- Extended by:
- Forwardable
- Defined in:
- lib/terminal_calendar/selection/month_year_dialog.rb
Instance Method Summary collapse
-
#initialize(input: $stdin, output: $stdout, env: ENV, interrupt: :error, track_history: true, start_at: Date.today) ⇒ MonthYearDialog
constructor
Initializes a new MonthYearDialog instance.
- #redraw(amt = 2) ⇒ Object
-
#render ⇒ Object
Renders the dialog for month and year to the output.
- #select ⇒ Object
Constructor Details
#initialize(input: $stdin, output: $stdout, env: ENV, interrupt: :error, track_history: true, start_at: Date.today) ⇒ MonthYearDialog
Initializes a new MonthYearDialog instance.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/terminal_calendar/selection/month_year_dialog.rb', line 16 def initialize(input: $stdin, output: $stdout, env: ENV, interrupt: :error, track_history: true, start_at: Date.today) @output = output @reader = TTY::Reader.new( input: input, output: output, interrupt: interrupt, track_history: track_history, env: env ) initialize_carousels(start_at) @cursor = TTY::Cursor end |
Instance Method Details
#redraw(amt = 2) ⇒ Object
45 46 47 48 |
# File 'lib/terminal_calendar/selection/month_year_dialog.rb', line 45 def redraw(amt=2) @output.print(cursor.clear_lines(amt)) amt == 2 ? render : year_car.render end |
#render ⇒ Object
Renders the dialog for month and year to the output
31 32 33 34 35 |
# File 'lib/terminal_calendar/selection/month_year_dialog.rb', line 31 def render month_car.render @output.puts year_car.render end |
#select ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/terminal_calendar/selection/month_year_dialog.rb', line 37 def select cursor.invisible do render key_capture end end |