Module: Themigrator::UI::ProgressWindow
- Includes:
- Curses
- Included in:
- Themigrator::UI
- Defined in:
- lib/themigrator/progress_window.rb,
lib/themigrator/ui/progress_window.rb
Instance Method Summary collapse
- #build_status_line ⇒ Object
- #pg_set_action(action) ⇒ Object
- #progress_window ⇒ Object
- #render_progress ⇒ Object
- #say(*msg) ⇒ Object
Instance Method Details
#build_status_line ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/themigrator/ui/progress_window.rb', line 28 def build_status_line scripts = Themigrator::Migration::SCRIPTS width = scripts.map(&:size).inject(&:+) free_space = @cols - width sep_space = scripts.size - 1 inline_space = ((free_space - sep_space) / scripts.size - 1) / 2 action_msg = [] scripts.map do |script| a = '' inline_space.times { a << ' ' } a << if defined?(@pg_action) && @pg_action.to_s == script.to_s script.upcase else script.downcase end inline_space.times { a << ' ' } action_msg << a end action_msg.join('>') end |
#pg_set_action(action) ⇒ Object
14 15 16 |
# File 'lib/themigrator/ui/progress_window.rb', line 14 def pg_set_action(action) @pg_action = action end |
#progress_window ⇒ Object
13 14 15 16 17 |
# File 'lib/themigrator/progress_window.rb', line 13 def progress_window @progress_widnow ||= Window.new(@lines - 1, @cols - 1, @lines - 1, 0).tap do |w| w.attrset(A_DIM) end end |
#render_progress ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/themigrator/progress_window.rb', line 5 def render_progress progress_window.setpos(0, 0) progress_window.addstr(@pm.roles.inspect) progress_window.addstr(@pm.current_action.inspect) progress_window.addstr(@action) progress_window.refresh end |
#say(*msg) ⇒ Object
24 25 26 |
# File 'lib/themigrator/ui/progress_window.rb', line 24 def say(*msg) @pw_status = msg.map(&:to_s).join(' ') end |