Class: HTTP::Protocol::HTTP2::Window

Inherits:
Object
  • Object
show all
Defined in:
lib/http/protocol/http2/window_update_frame.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#capacityObject

Returns the value of attribute capacity.



42
43
44
# File 'lib/http/protocol/http2/window_update_frame.rb', line 42

def capacity
  @capacity
end

#usedObject

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

#availableObject



48
49
50
# File 'lib/http/protocol/http2/window_update_frame.rb', line 48

def available
	@capacity - @used
end

#available?Boolean

Returns:

  • (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

#dupObject



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 expand(amount)
	@used -= amount
end

#full?Boolean

The window is completely full?

Returns:

  • (Boolean)


37
38
39
# File 'lib/http/protocol/http2/window_update_frame.rb', line 37

def full?
	@used == @capacity
end

#limited?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/http/protocol/http2/window_update_frame.rb', line 60

def limited?
	@used > (@capacity / 2)
end

#to_sObject



64
65
66
# File 'lib/http/protocol/http2/window_update_frame.rb', line 64

def to_s
	"\#<Window #{@used}/#{@capacity}>"
end