Class: Spielbash::CommandAction

Inherits:
BaseAction show all
Defined in:
lib/spielbash/model/action/command_action.rb

Instance Attribute Summary collapse

Attributes inherited from BaseAction

#action_context

Instance Method Summary collapse

Constructor Details

#initialize(command, action_context) ⇒ CommandAction

Returns a new instance of CommandAction.



5
6
7
8
# File 'lib/spielbash/model/action/command_action.rb', line 5

def initialize(command, action_context)
  super(action_context)
  @command = command
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



3
4
5
# File 'lib/spielbash/model/action/command_action.rb', line 3

def command
  @command
end

Instance Method Details

#execute(session) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/spielbash/model/action/command_action.rb', line 10

def execute(session)
  command.each_char do |c|
    session.send_key(c)
    sleep(action_context.typing_delay_s)
  end
  session.send_key('C-m')

  session.wait if action_context.wait

  sleep(action_context.reading_delay_s)
end