class GitObjectBrowser::Models::Bindata
Public Class Methods
new(input)
click to toggle source
# File lib/git-object-browser/models/bindata.rb, line 7 def initialize(input) @in = input end
Public Instance Methods
binstr(bytes)
click to toggle source
# File lib/git-object-browser/models/bindata.rb, line 39 def binstr(bytes) @in.read(bytes).unpack('B*').first end
byte()
click to toggle source
# File lib/git-object-browser/models/bindata.rb, line 27 def byte bytes(1).first end
bytes(bytes)
click to toggle source
# File lib/git-object-browser/models/bindata.rb, line 23 def bytes(bytes) @in.read(bytes).unpack('C*') end
find_char(char)
click to toggle source
# File lib/git-object-browser/models/bindata.rb, line 43 def find_char(char) buf = '' loop do c = @in.read(1) return buf if c.nil? || c == char buf += c end end
hex(bytes)
click to toggle source
# File lib/git-object-browser/models/bindata.rb, line 35 def hex(bytes) @in.read(bytes).unpack('H*').first end
int()
click to toggle source
# File lib/git-object-browser/models/bindata.rb, line 31 def int @in.read(4).unpack('N').first.to_i end
peek(bytes)
click to toggle source
# File lib/git-object-browser/models/bindata.rb, line 60 def peek(bytes) result = raw(bytes) @in.seek(bytes * -1, IO::SEEK_CUR) result end
raw(bytes)
click to toggle source
# File lib/git-object-browser/models/bindata.rb, line 19 def raw(bytes) @in.read(bytes) end
seek(bytes)
click to toggle source
# File lib/git-object-browser/models/bindata.rb, line 56 def seek(bytes) @in.seek(bytes) end
skip(bytes)
click to toggle source
# File lib/git-object-browser/models/bindata.rb, line 52 def skip(bytes) @in.seek(bytes, IO::SEEK_CUR) end
switch_source(input) { || ... }
click to toggle source
# File lib/git-object-browser/models/bindata.rb, line 11 def switch_source(input) tmp = @in @in = input yield ensure @in = tmp end