Class: NexusSW::LXD::Transport::Mixins::Helpers::ExecuteMixin::InteractiveResult

Inherits:
ExecuteResult
  • Object
show all
Defined in:
lib/nexussw/lxd/transport/mixins/helpers/execute.rb

Instance Attribute Summary collapse

Attributes inherited from ExecuteResult

#command, #options

Instance Method Summary collapse

Methods inherited from ExecuteResult

#error?, #stderr, #stdout

Constructor Details

#initialize(command, options, stdin, thread = nil) ⇒ InteractiveResult

Returns a new instance of InteractiveResult.



58
59
60
61
62
# File 'lib/nexussw/lxd/transport/mixins/helpers/execute.rb', line 58

def initialize(command, options, stdin, thread = nil)
  super(command, options, nil)
  @stdin = stdin
  @thread = thread
end

Instance Attribute Details

#exitstatusObject

Returns the value of attribute exitstatus.



65
66
67
# File 'lib/nexussw/lxd/transport/mixins/helpers/execute.rb', line 65

def exitstatus
  @exitstatus
end

#stdinObject (readonly)

Returns the value of attribute stdin.



64
65
66
# File 'lib/nexussw/lxd/transport/mixins/helpers/execute.rb', line 64

def stdin
  @stdin
end

#threadObject (readonly)

Returns the value of attribute thread.



64
65
66
# File 'lib/nexussw/lxd/transport/mixins/helpers/execute.rb', line 64

def thread
  @thread
end

Instance Method Details

#capture_output(&block) ⇒ Object



67
68
69
# File 'lib/nexussw/lxd/transport/mixins/helpers/execute.rb', line 67

def capture_output(&block)
  @block = block if block_given?
end

#error!Object



80
81
82
83
# File 'lib/nexussw/lxd/transport/mixins/helpers/execute.rb', line 80

def error!
  thread.join if thread.respond_to? :join
  super
end

#send_output(stdout_chunk) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/nexussw/lxd/transport/mixins/helpers/execute.rb', line 71

def send_output(stdout_chunk)
  loop do
    break if @block
    sleep 0.1
    Thread.pass
  end
  @block.call stdout_chunk
end