Class: Doom::Game::Snapshot::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/doom/game/snapshot.rb

Instance Method Summary collapse

Constructor Details

#initialize(bytes) ⇒ Reader

Returns a new instance of Reader.



63
64
65
66
# File 'lib/doom/game/snapshot.rb', line 63

def initialize(bytes)
  @buf = bytes.b
  @pos = 0
end

Instance Method Details

#boolObject



73
# File 'lib/doom/game/snapshot.rb', line 73

def bool = u8 == 1

#f64Object



72
# File 'lib/doom/game/snapshot.rb', line 72

def f64 = take(8).unpack1('E')

#i64Object



71
# File 'lib/doom/game/snapshot.rb', line 71

def i64 = take(8).unpack1('q<')

#listObject



79
80
81
# File 'lib/doom/game/snapshot.rb', line 79

def list(&)
  Array.new(u32, &)
end

#strObject



75
76
77
# File 'lib/doom/game/snapshot.rb', line 75

def str
  take(u16)
end

#u16Object



69
# File 'lib/doom/game/snapshot.rb', line 69

def u16 = take(2).unpack1('S<')

#u32Object



70
# File 'lib/doom/game/snapshot.rb', line 70

def u32 = take(4).unpack1('L<')

#u8Object



68
# File 'lib/doom/game/snapshot.rb', line 68

def u8  = take(1).unpack1('C')