Class: Rbzlib::Posf

Inherits:
Bytef_str show all
Defined in:
lib/pr/rbzlib/posf.rb

Instance Attribute Summary

Attributes inherited from Bytef_str

#buffer, #offset

Instance Method Summary collapse

Methods inherited from Bytef_str

#current, #initialize, #length

Constructor Details

This class inherits a constructor from Rbzlib::Bytef_str

Instance Method Details

#+(inc) ⇒ Object



7
8
9
10
# File 'lib/pr/rbzlib/posf.rb', line 7

def +(inc)
  @offset += inc * 2
  self
end

#-(dec) ⇒ Object



12
13
14
15
# File 'lib/pr/rbzlib/posf.rb', line 12

def -(dec)
  @offset -= dec * 2
  self
end

#[](idx) ⇒ Object



17
18
19
# File 'lib/pr/rbzlib/posf.rb', line 17

def [](idx)
  @buffer[(idx * 2) + @offset, 2].unpack('v').first
end

#[]=(idx, val) ⇒ Object



21
22
23
# File 'lib/pr/rbzlib/posf.rb', line 21

def []=(idx, val)
  @buffer[(idx * 2) + @offset, 2] = [val].pack('v')
end

#getObject



25
26
27
# File 'lib/pr/rbzlib/posf.rb', line 25

def get
  @buffer[@offset, 2].unpack('v').first
end

#set(val) ⇒ Object



29
30
31
# File 'lib/pr/rbzlib/posf.rb', line 29

def set(val)
  @buffer[@offset, 2] = [val].pack('v')
end