Class: HTTP::Protocol::HTTP2::Window
- Inherits:
-
Object
- Object
- HTTP::Protocol::HTTP2::Window
- Defined in:
- lib/http/protocol/http2/window_update_frame.rb
Instance Attribute Summary collapse
-
#capacity ⇒ Object
Returns the value of attribute capacity.
-
#used ⇒ Object
Returns the value of attribute used.
Instance Method Summary collapse
- #available ⇒ Object
- #available? ⇒ Boolean
- #consume(amount) ⇒ Object
- #dup ⇒ Object
- #expand(amount) ⇒ Object
-
#full? ⇒ Boolean
The window is completely full?.
-
#initialize(capacity) ⇒ Window
constructor
A new instance of Window.
- #limited? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(capacity) ⇒ Window
Returns a new instance of Window.
25 26 27 28 29 30 |
# File 'lib/http/protocol/http2/window_update_frame.rb', line 25 def initialize(capacity) @used = 0 @capacity = capacity fail unless capacity end |
Instance Attribute Details
#capacity ⇒ Object
Returns the value of attribute capacity.
42 43 44 |
# File 'lib/http/protocol/http2/window_update_frame.rb', line 42 def capacity @capacity end |
#used ⇒ Object
Returns the value of attribute used.
41 42 43 |
# File 'lib/http/protocol/http2/window_update_frame.rb', line 41 def used @used end |
Instance Method Details
#available ⇒ Object
48 49 50 |
# File 'lib/http/protocol/http2/window_update_frame.rb', line 48 def available @capacity - @used end |
#available? ⇒ Boolean
52 53 54 |
# File 'lib/http/protocol/http2/window_update_frame.rb', line 52 def available? available > 0 end |
#consume(amount) ⇒ Object
44 45 46 |
# File 'lib/http/protocol/http2/window_update_frame.rb', line 44 def consume(amount) @used += amount end |
#dup ⇒ Object
32 33 34 |
# File 'lib/http/protocol/http2/window_update_frame.rb', line 32 def dup return self.class.new(@capacity) end |
#expand(amount) ⇒ Object
56 57 58 |
# File 'lib/http/protocol/http2/window_update_frame.rb', line 56 def (amount) @used -= amount end |
#full? ⇒ Boolean
The window is completely full?
37 38 39 |
# File 'lib/http/protocol/http2/window_update_frame.rb', line 37 def full? @used == @capacity end |
#limited? ⇒ Boolean
60 61 62 |
# File 'lib/http/protocol/http2/window_update_frame.rb', line 60 def limited? @used > (@capacity / 2) end |
#to_s ⇒ Object
64 65 66 |
# File 'lib/http/protocol/http2/window_update_frame.rb', line 64 def to_s "\#<Window #{@used}/#{@capacity}>" end |