class PuTTY::Key::PPK::GetbyteIo

Wraps an IO-like instance, providing an implementation of #getbyte. Allows reading from IO-like instances that only provide #read.

Public Class Methods

new(io) click to toggle source

Initializes a new {GetbyteIO} with the given IO-like instance.

@param io [Object] An IO-like instance.

# File lib/putty/key/ppk.rb, line 644
def initialize(io)
  @io = io
  @outbuf = ' '.b
end

Public Instance Methods

getbyte() click to toggle source

Gets the next 8-bit byte (0..255) from the IO-like instance.

@return [Integer] the next byte or nil if the end of the stream has been reached.

# File lib/putty/key/ppk.rb, line 653
def getbyte
  s = @io.read(1, @outbuf)
  s && s.getbyte(0)
end