Class: Pecorino::LeakyBucket::State
- Inherits:
-
Object
- Object
- Pecorino::LeakyBucket::State
- Defined in:
- lib/pecorino/leaky_bucket.rb
Overview
Returned from ‘.state` and `.fillup`
Direct Known Subclasses
Instance Attribute Summary collapse
-
#level ⇒ Float
readonly
Returns the level of the bucket.
Instance Method Summary collapse
-
#full? ⇒ Boolean
(also: #full)
Tells whether the bucket was detected to be full when the operation on the LeakyBucket was performed.
-
#initialize(level, is_full) ⇒ State
constructor
A new instance of State.
Constructor Details
#initialize(level, is_full) ⇒ State
Returns a new instance of State.
30 31 32 33 |
# File 'lib/pecorino/leaky_bucket.rb', line 30 def initialize(level, is_full) @level = level.to_f @full = !!is_full end |
Instance Attribute Details
#level ⇒ Float (readonly)
Returns the level of the bucket
37 38 39 |
# File 'lib/pecorino/leaky_bucket.rb', line 37 def level @level end |
Instance Method Details
#full? ⇒ Boolean Also known as: full
Tells whether the bucket was detected to be full when the operation on the LeakyBucket was performed.
42 43 44 |
# File 'lib/pecorino/leaky_bucket.rb', line 42 def full? @full end |