Class: R10K::Util::Subprocess::Runner::Pump Private

Inherits:
Object
  • Object
show all
Defined in:
lib/r10k/util/subprocess/runner/pump.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Perform nonblocking reads on a streaming IO instance.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ Pump

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Pump.



20
21
22
23
24
25
26
27
# File 'lib/r10k/util/subprocess/runner/pump.rb', line 20

def initialize(io)
  @io     = io
  @thread = nil
  @string = ''
  @run    = true
  @min_delay = 0.05
  @max_delay = 1.0
end

Instance Attribute Details

#max_delayFloat

Returns The maximum time to wait while polling the IO device.

Returns:

  • (Float)

    The maximum time to wait while polling the IO device



18
19
20
# File 'lib/r10k/util/subprocess/runner/pump.rb', line 18

def max_delay
  @max_delay
end

#min_delayFloat

Returns The minimum time to wait while polling the IO device.

Returns:

  • (Float)

    The minimum time to wait while polling the IO device



14
15
16
# File 'lib/r10k/util/subprocess/runner/pump.rb', line 14

def min_delay
  @min_delay
end

#stringObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

!@attribute [r] string

@return [String] The output collected from the IO device


10
11
12
# File 'lib/r10k/util/subprocess/runner/pump.rb', line 10

def string
  @string
end

Instance Method Details

#halt!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



33
34
35
36
# File 'lib/r10k/util/subprocess/runner/pump.rb', line 33

def halt!
  @run = false
  @thread.join
end

#startObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/r10k/util/subprocess/runner/pump.rb', line 29

def start
  @thread = Thread.new { pump }
end

#waitObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Block until the pumping thread reaches EOF on the IO object.



39
40
41
# File 'lib/r10k/util/subprocess/runner/pump.rb', line 39

def wait
  @thread.join
end