Class: NexusSW::LXD::Transport::Mixins::Rest::StdinStub
- Inherits:
-
Object
- Object
- NexusSW::LXD::Transport::Mixins::Rest::StdinStub
- Defined in:
- lib/nexussw/lxd/transport/mixins/rest.rb
Instance Attribute Summary collapse
-
#driver ⇒ Object
readonly
Returns the value of attribute driver.
Class Method Summary collapse
-
.pipe(driver) ⇒ Object
return a real IO object for parity with Local Transport.
- .read(monitor) ⇒ Object
Instance Method Summary collapse
-
#initialize(driver) ⇒ StdinStub
constructor
return self as an IO (un)like object.
- #write(data) ⇒ Object
Constructor Details
#initialize(driver) ⇒ StdinStub
return self as an IO (un)like object
27 28 29 |
# File 'lib/nexussw/lxd/transport/mixins/rest.rb', line 27 def initialize(driver) @driver = driver end |
Instance Attribute Details
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
30 31 32 |
# File 'lib/nexussw/lxd/transport/mixins/rest.rb', line 30 def driver @driver end |
Class Method Details
.pipe(driver) ⇒ Object
return a real IO object for parity with Local Transport
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/nexussw/lxd/transport/mixins/rest.rb', line 33 def self.pipe(driver) NIO::WebSocket::Reactor.start reader, writer = IO.pipe NIO::WebSocket::Reactor.queue_task do iomon = NIO::WebSocket::Reactor.selector.register(reader, :r) iomon.value = proc do data = read(iomon) driver.binary data if data end end writer end |
.read(monitor) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/nexussw/lxd/transport/mixins/rest.rb', line 50 def self.read(monitor) monitor.io.read_nonblock(16384) rescue IO::WaitReadable # rubocop:disable Lint/ShadowedException return nil rescue Errno::ECONNRESET, EOFError, IOError monitor.close return nil end |
Instance Method Details
#write(data) ⇒ Object
46 47 48 |
# File 'lib/nexussw/lxd/transport/mixins/rest.rb', line 46 def write(data) driver.binary data end |