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.
294 295 296 |
# File 'lib/rinda/tuplespace.rb', line 294 def initialize @bin = [] end |
Instance Method Details
#add(tuple) ⇒ Object
298 299 300 |
# File 'lib/rinda/tuplespace.rb', line 298 def add(tuple) @bin.push(tuple) end |
#delete(tuple) ⇒ Object
302 303 304 305 |
# File 'lib/rinda/tuplespace.rb', line 302 def delete(tuple) idx = @bin.rindex(tuple) @bin.delete_at(idx) if idx end |
#find ⇒ Object
307 308 309 310 311 312 |
# File 'lib/rinda/tuplespace.rb', line 307 def find @bin.reverse_each do |x| return x if yield(x) end nil end |