Class: GitObjectBrowser::Models::Bindata
- Inherits:
-
Object
- Object
- GitObjectBrowser::Models::Bindata
show all
- Defined in:
- lib/git-object-browser/models/bindata.rb
Instance Method Summary
collapse
Constructor Details
#initialize(input) ⇒ Bindata
Returns a new instance of Bindata.
7
8
9
|
# File 'lib/git-object-browser/models/bindata.rb', line 7
def initialize(input)
@in = input
end
|
Instance Method Details
#binstr(bytes) ⇒ Object
39
40
41
|
# File 'lib/git-object-browser/models/bindata.rb', line 39
def binstr(bytes)
@in.read(bytes).unpack('B*').first
end
|
#byte ⇒ Object
27
28
29
|
# File 'lib/git-object-browser/models/bindata.rb', line 27
def byte
bytes(1).first
end
|
#bytes(bytes) ⇒ Object
23
24
25
|
# File 'lib/git-object-browser/models/bindata.rb', line 23
def bytes(bytes)
@in.read(bytes).unpack('C*')
end
|
#find_char(char) ⇒ Object
43
44
45
46
47
48
49
50
|
# 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) ⇒ Object
35
36
37
|
# File 'lib/git-object-browser/models/bindata.rb', line 35
def hex(bytes)
@in.read(bytes).unpack('H*').first
end
|
#int ⇒ Object
31
32
33
|
# File 'lib/git-object-browser/models/bindata.rb', line 31
def int
@in.read(4).unpack('N').first.to_i
end
|
#peek(bytes) ⇒ Object
60
61
62
63
64
|
# 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) ⇒ Object
19
20
21
|
# File 'lib/git-object-browser/models/bindata.rb', line 19
def raw(bytes)
@in.read(bytes)
end
|
#seek(bytes) ⇒ Object
56
57
58
|
# File 'lib/git-object-browser/models/bindata.rb', line 56
def seek(bytes)
@in.seek(bytes)
end
|
#skip(bytes) ⇒ Object
52
53
54
|
# File 'lib/git-object-browser/models/bindata.rb', line 52
def skip(bytes)
@in.seek(bytes, IO::SEEK_CUR)
end
|
#switch_source(input) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/git-object-browser/models/bindata.rb', line 11
def switch_source(input)
tmp = @in
@in = input
yield
ensure
@in = tmp
end
|