Class: MindControl::CUI
- Inherits:
-
Object
- Object
- MindControl::CUI
- Defined in:
- lib/mind_control/cui.rb
Overview
Console User Interface.
Instance Attribute Summary collapse
-
#highline ⇒ Object
readonly
Returns the value of attribute highline.
Instance Method Summary collapse
-
#initialize(stdin = STDIN, stdout = STDOUT) ⇒ CUI
constructor
A new instance of CUI.
-
#select_process(process_list) ⇒ MindControl::Client::Process
Ask user to select process from list.
-
#show_debug(message) ⇒ Object
Show debug message.
-
#show_error(message) ⇒ Object
Show error message.
Constructor Details
#initialize(stdin = STDIN, stdout = STDOUT) ⇒ CUI
Returns a new instance of CUI.
15 16 17 |
# File 'lib/mind_control/cui.rb', line 15 def initialize( stdin = STDIN, stdout = STDOUT ) @highline = ::HighLine.new( stdin, stdout ) end |
Instance Attribute Details
#highline ⇒ Object (readonly)
Returns the value of attribute highline.
9 10 11 |
# File 'lib/mind_control/cui.rb', line 9 def highline @highline end |
Instance Method Details
#select_process(process_list) ⇒ MindControl::Client::Process
Ask user to select process from list.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mind_control/cui.rb', line 25 def select_process( process_list ) highline.choose do || .header = "Select process" .select_by = :index process_list.each do |process| .choice( "#{process.name} (PID: #{process.pid})" ) { process } end end end |
#show_debug(message) ⇒ Object
Show debug message.
40 41 42 |
# File 'lib/mind_control/cui.rb', line 40 def show_debug( ) highline.say HighLine::String.new( ).white end |
#show_error(message) ⇒ Object
Show error message.
48 49 50 |
# File 'lib/mind_control/cui.rb', line 48 def show_error( ) highline.say HighLine::String.new( ).red end |