Class: Caffeinate::Dripper::Drip::DripCollection
- Inherits:
-
Object
- Object
- Caffeinate::Dripper::Drip::DripCollection
- Includes:
- Enumerable
- Defined in:
- lib/caffeinate/dripper/drip.rb
Overview
A collection of Drip objects for a ‘Caffeinate::Dripper`
Instance Method Summary collapse
- #[](val) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(dripper) ⇒ DripCollection
constructor
A new instance of DripCollection.
-
#register(action, options, &block) ⇒ Object
Register the drip.
- #size ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(dripper) ⇒ DripCollection
Returns a new instance of DripCollection.
11 12 13 14 |
# File 'lib/caffeinate/dripper/drip.rb', line 11 def initialize(dripper) @dripper = dripper @drips = {} end |
Instance Method Details
#[](val) ⇒ Object
33 34 35 |
# File 'lib/caffeinate/dripper/drip.rb', line 33 def [](val) @drips[val] end |
#each(&block) ⇒ Object
21 22 23 |
# File 'lib/caffeinate/dripper/drip.rb', line 21 def each(&block) @drips.each { |action_name, drip| block.call(action_name, drip) } end |
#register(action, options, &block) ⇒ Object
Register the drip
17 18 19 |
# File 'lib/caffeinate/dripper/drip.rb', line 17 def register(action, , &block) @drips[action.to_s] = ::Caffeinate::Drip.new(@dripper, action, , &block) end |
#size ⇒ Object
29 30 31 |
# File 'lib/caffeinate/dripper/drip.rb', line 29 def size @drips.size end |
#values ⇒ Object
25 26 27 |
# File 'lib/caffeinate/dripper/drip.rb', line 25 def values @drips.values end |