Class: BitBroker::Solvant::Chunk

Inherits:
Object
  • Object
show all
Defined in:
lib/bitbroker/solvant.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Chunk

Returns a new instance of Chunk.



66
67
68
69
70
71
72
# File 'lib/bitbroker/solvant.rb', line 66

def initialize(opts)
  @r_path = opts[:r_path]
  @f_path = opts[:f_path]
  @size = opts[:size]
  @offset = opts[:offset]
  @chunk_size = opts[:chunk_size]
end

Instance Method Details

#serializeObject



74
75
76
77
78
79
80
81
# File 'lib/bitbroker/solvant.rb', line 74

def serialize
  MessagePack.pack({
    'path' => @r_path,
    'data' => File.binread(@f_path, @size, @offset * @chunk_size),
    'offset' => @offset,
    'chunk_size' => @chunk_size,
  })
end