Class: MindControl::CUI

Inherits:
Object
  • Object
show all
Defined in:
lib/mind_control/cui.rb

Overview

Console User Interface.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stdin = STDIN, stdout = STDOUT) ⇒ CUI

Returns a new instance of CUI.

Parameters:

  • stdin (IO) (defaults to: STDIN)

    (STDIN) Console input.

  • stdout (IO) (defaults to: STDOUT)

    (STDOUT) Console output.



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

#highlineObject (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.

Parameters:

Returns:



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 |menu|
    menu.header    = "Select process"
    menu.select_by = :index

    process_list.each do |process|
      menu.choice( "#{process.name} (PID: #{process.pid})" ) { process }
    end
  end
end

#show_debug(message) ⇒ Object

Show debug message.

Parameters:

  • message (String)


40
41
42
# File 'lib/mind_control/cui.rb', line 40

def show_debug( message )
  highline.say HighLine::String.new( message ).white
end

#show_error(message) ⇒ Object

Show error message.

Parameters:

  • message (String)


48
49
50
# File 'lib/mind_control/cui.rb', line 48

def show_error( message )
  highline.say HighLine::String.new( message ).red
end