Class: Rinda::TupleBag::TupleBin
- Inherits:
-
Object
- Object
- Rinda::TupleBag::TupleBin
- Extended by:
- Forwardable
- Defined in:
- lib/rinda/tuplespace.rb
Instance Method Summary collapse
- #add(tuple) ⇒ Object
- #delete(tuple) ⇒ Object
- #find ⇒ Object
-
#initialize ⇒ TupleBin
constructor
A new instance of TupleBin.
Constructor Details
#initialize ⇒ TupleBin
Returns a new instance of TupleBin.
295 296 297 |
# File 'lib/rinda/tuplespace.rb', line 295 def initialize @bin = [] end |
Instance Method Details
#add(tuple) ⇒ Object
299 300 301 |
# File 'lib/rinda/tuplespace.rb', line 299 def add(tuple) @bin.push(tuple) end |
#delete(tuple) ⇒ Object
303 304 305 306 |
# File 'lib/rinda/tuplespace.rb', line 303 def delete(tuple) idx = @bin.rindex(tuple) @bin.delete_at(idx) if idx end |
#find ⇒ Object
308 309 310 311 312 313 |
# File 'lib/rinda/tuplespace.rb', line 308 def find @bin.reverse_each do |x| return x if yield(x) end nil end |