Class: RuneRb::Cache::Index
- Inherits:
-
Object
- Object
- RuneRb::Cache::Index
- Includes:
- RuneRb::Core::Logging
- Defined in:
- lib/rune/cache/index.rb
Overview
An instance of a CacheIndex points to a file in the ‘main_file_cache.dat` file.
Instance Attribute Summary collapse
-
#block ⇒ Integer
readonly
The block of the file.
-
#size ⇒ Integer
readonly
The size of the file.
Class Method Summary collapse
-
.decode(buffer) ⇒ Object
Decodes a buffer into an index.
Instance Method Summary collapse
-
#initialize(size, block) ⇒ Index
constructor
Constructs a new Cache Index given the block size and identifier.
Methods included from RuneRb::Core::Logging
Constructor Details
#initialize(size, block) ⇒ Index
Constructs a new Cache Index given the block size and identifier.
19 20 21 22 |
# File 'lib/rune/cache/index.rb', line 19 def initialize(size, block) @size = size @block = block end |
Instance Attribute Details
#block ⇒ Integer (readonly)
Note:
This attribute is read-only.
Returns the block of the file.
14 15 16 |
# File 'lib/rune/cache/index.rb', line 14 def block @block end |
#size ⇒ Integer (readonly)
Note:
This attribute is read-only.
Returns the size of the file.
9 10 11 |
# File 'lib/rune/cache/index.rb', line 9 def size @size end |
Class Method Details
.decode(buffer) ⇒ Object
Decodes a buffer into an index.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rune/cache/index.rb', line 26 def self.decode(buffer) #raise "Unexpected buffer length. Buffer #{buffer.bytesize}, Expected: #{RuneRb::Core::INDEX_SIZE}" unless buffer.bytesize == RuneRb::Core::INDEX_SIZE bytes = buffer.unpack('C*') size = bytes[0] << 16 | bytes[1] << 8 | bytes[2] block = bytes[3] << 16 | bytes[4] << 8 | bytes[5] info "Decoded index: size: #{size}, block: #{block}" RuneRb::Cache::Index.new(size, block) end |