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
31 32 33 |
# File 'lib/nexussw/lxd/transport/mixins/rest.rb', line 31 def initialize(driver) @driver = driver end |
Instance Attribute Details
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
34 35 36 |
# File 'lib/nexussw/lxd/transport/mixins/rest.rb', line 34 def driver @driver end |
Class Method Details
.pipe(driver) ⇒ Object
return a real IO object for parity with Local Transport
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/nexussw/lxd/transport/mixins/rest.rb', line 37 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
54 55 56 57 58 59 60 61 |
# File 'lib/nexussw/lxd/transport/mixins/rest.rb', line 54 def self.read(monitor) monitor.io.read_nonblock(16384) rescue IO::WaitReadable # rubocop:disable Lint/ShadowedException nil rescue Errno::ECONNRESET, EOFError, IOError monitor.close nil end |
Instance Method Details
#write(data) ⇒ Object
50 51 52 |
# File 'lib/nexussw/lxd/transport/mixins/rest.rb', line 50 def write(data) driver.binary data end |