Class: Biryani::Window
- Inherits:
-
Object
- Object
- Biryani::Window
- Defined in:
- lib/biryani/window.rb
Instance Attribute Summary collapse
-
#capacity ⇒ Object
readonly
Returns the value of attribute capacity.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
Instance Method Summary collapse
- #consume!(length) ⇒ Integer
- #increase!(length) ⇒ Integer
-
#initialize(initial_window_size) ⇒ Window
constructor
A new instance of Window.
- #update!(initial_window_size) ⇒ Integer
Constructor Details
#initialize(initial_window_size) ⇒ Window
Returns a new instance of Window.
6 7 8 9 |
# File 'lib/biryani/window.rb', line 6 def initialize(initial_window_size) @length = initial_window_size @capacity = initial_window_size end |
Instance Attribute Details
#capacity ⇒ Object (readonly)
Returns the value of attribute capacity.
3 4 5 |
# File 'lib/biryani/window.rb', line 3 def capacity @capacity end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
3 4 5 |
# File 'lib/biryani/window.rb', line 3 def length @length end |
Instance Method Details
#consume!(length) ⇒ Integer
14 15 16 |
# File 'lib/biryani/window.rb', line 14 def consume!(length) @length -= length end |
#increase!(length) ⇒ Integer
21 22 23 |
# File 'lib/biryani/window.rb', line 21 def increase!(length) @length += length end |
#update!(initial_window_size) ⇒ Integer
28 29 30 31 32 |
# File 'lib/biryani/window.rb', line 28 def update!(initial_window_size) @length = initial_window_size - @capacity + @length @capacity = initial_window_size @length end |