Class: SshTresor::SSHEncoding::Reader
- Inherits:
-
Object
- Object
- SshTresor::SSHEncoding::Reader
- Defined in:
- lib/ssh_tresor/ssh_encoding.rb
Instance Method Summary collapse
- #byte ⇒ Object
- #eof? ⇒ Boolean
-
#initialize(data) ⇒ Reader
constructor
A new instance of Reader.
- #string ⇒ Object
- #uint32 ⇒ Object
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
#byte ⇒ Object
26 27 28 |
# File 'lib/ssh_tresor/ssh_encoding.rb', line 26 def byte read(1).getbyte(0) end |
#eof? ⇒ Boolean
39 40 41 |
# File 'lib/ssh_tresor/ssh_encoding.rb', line 39 def eof? @offset == @data.bytesize end |
#string ⇒ Object
34 35 36 37 |
# File 'lib/ssh_tresor/ssh_encoding.rb', line 34 def string length = uint32 read(length) end |
#uint32 ⇒ Object
30 31 32 |
# File 'lib/ssh_tresor/ssh_encoding.rb', line 30 def uint32 read(4).unpack1("N") end |