Class: DTAS::Nonblock

Inherits:
IO
  • Object
show all
Defined in:
lib/dtas/nonblock.rb

Overview

Copyright © 2015-2016 all contributors <[email protected]> License: GPL-3.0+ <www.gnu.org/licenses/gpl-3.0.txt>

Direct Known Subclasses

Pipe

Constant Summary collapse

EX =
{}.freeze

Instance Method Summary collapse

Instance Method Details

#read_nonblock(len, buf = nil, opts = EX) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/dtas/nonblock.rb', line 7

def read_nonblock(len, buf = nil, opts = EX)
  super(len, buf)
rescue IO::WaitReadable
  raise if opts[:exception]
  :wait_readable
rescue EOFError
  raise if opts[:exception]
  nil
end

#write_nonblock(buf, opts = EX) ⇒ Object



17
18
19
20
21
22
# File 'lib/dtas/nonblock.rb', line 17

def write_nonblock(buf, opts = EX)
  super(buf)
rescue IO::WaitWritable
  raise if opts[:exception]
  :wait_writable
end