Class: Yap::Shell::Execution::CommandExecution

Inherits:
Object
  • Object
show all
Defined in:
lib/yap/shell/execution/command_execution.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stdin:, stdout:, stderr:, world:) ⇒ CommandExecution

Returns a new instance of CommandExecution.



13
14
15
16
# File 'lib/yap/shell/execution/command_execution.rb', line 13

def initialize(stdin:, stdout:, stderr:, world:)
  @stdin, @stdout, @stderr = stdin, stdout, stderr
  @world = world
end

Instance Attribute Details

#stderrObject (readonly)

Returns the value of attribute stderr.



3
4
5
# File 'lib/yap/shell/execution/command_execution.rb', line 3

def stderr
  @stderr
end

#stdinObject (readonly)

Returns the value of attribute stdin.



3
4
5
# File 'lib/yap/shell/execution/command_execution.rb', line 3

def stdin
  @stdin
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



3
4
5
# File 'lib/yap/shell/execution/command_execution.rb', line 3

def stdout
  @stdout
end

#worldObject (readonly)

Returns the value of attribute world.



3
4
5
# File 'lib/yap/shell/execution/command_execution.rb', line 3

def world
  @world
end

Class Method Details

.on_execute(&blk) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/yap/shell/execution/command_execution.rb', line 5

def self.on_execute(&blk)
  if block_given?
    @on_execute_blk = blk
  else
    @on_execute_blk
  end
end

Instance Method Details

#execute(command:, n:, of:, wait: true) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/yap/shell/execution/command_execution.rb', line 18

def execute(command:, n:, of:, wait:true)
  if self.class.on_execute
    self.instance_exec(command:command, n:n, of:of, wait:wait, &self.class.on_execute)
  else
    raise NotImplementedError, "on_execute block hasn't been implemented!"
  end
end

#suspended?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/yap/shell/execution/command_execution.rb', line 26

def suspended?
  @suspended
end