Class: SshTresor::SSHEncoding::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/ssh_tresor/ssh_encoding.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Reader

Returns a new instance of Reader.



21
22
23
24
# File 'lib/ssh_tresor/ssh_encoding.rb', line 21

def initialize(data)
  @data = data.b
  @offset = 0
end

Instance Method Details

#byteObject



26
27
28
# File 'lib/ssh_tresor/ssh_encoding.rb', line 26

def byte
  read(1).getbyte(0)
end

#eof?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/ssh_tresor/ssh_encoding.rb', line 39

def eof?
  @offset == @data.bytesize
end

#stringObject



34
35
36
37
# File 'lib/ssh_tresor/ssh_encoding.rb', line 34

def string
  length = uint32
  read(length)
end

#uint32Object



30
31
32
# File 'lib/ssh_tresor/ssh_encoding.rb', line 30

def uint32
  read(4).unpack1("N")
end