Class: DistributedStorage
Instance Method Summary collapse
- #<<(storage) ⇒ Object
- #close ⇒ Object
-
#initialize ⇒ DistributedStorage
constructor
A new instance of DistributedStorage.
- #open ⇒ Object
- #put(piece_hash, piece) ⇒ Object
Methods inherited from Storage
Constructor Details
#initialize ⇒ DistributedStorage
Returns a new instance of DistributedStorage.
286 287 288 |
# File 'lib/immutablebox.rb', line 286 def initialize @storages = [] end |
Instance Method Details
#<<(storage) ⇒ Object
289 290 291 292 |
# File 'lib/immutablebox.rb', line 289 def <<(storage) @storages << storage self end |
#close ⇒ Object
296 297 298 |
# File 'lib/immutablebox.rb', line 296 def close @storages.each(&:close) end |
#open ⇒ Object
293 294 295 |
# File 'lib/immutablebox.rb', line 293 def open @storages.each(&:open) end |
#put(piece_hash, piece) ⇒ Object
299 300 301 302 |
# File 'lib/immutablebox.rb', line 299 def put(piece_hash, piece) dice = piece_hash.unpack('L').first % @storages.size @storages[dice].put(piece_hash, piece) end |