Class: Arf::Wire::Stream::State
- Inherits:
-
Object
- Object
- Arf::Wire::Stream::State
- Defined in:
- lib/arf/wire/stream/state.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#error ⇒ Object
Returns the value of attribute error.
Instance Method Summary collapse
- #close ⇒ Object
- #close_local ⇒ Object
- #close_remote ⇒ Object
- #closed? ⇒ Boolean
-
#initialize ⇒ State
constructor
A new instance of State.
- #local_closed? ⇒ Boolean
- #may_receive_data? ⇒ Boolean
- #may_reset_stream? ⇒ Boolean
- #may_send_data? ⇒ Boolean
- #may_send_reset_stream? ⇒ Boolean
- #remote_closed? ⇒ Boolean
Constructor Details
#initialize ⇒ State
Returns a new instance of State.
10 11 12 13 |
# File 'lib/arf/wire/stream/state.rb', line 10 def initialize @code = :open @error = nil end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
7 8 9 |
# File 'lib/arf/wire/stream/state.rb', line 7 def code @code end |
#error ⇒ Object
Returns the value of attribute error.
8 9 10 |
# File 'lib/arf/wire/stream/state.rb', line 8 def error @error end |
Instance Method Details
#close ⇒ Object
15 16 17 |
# File 'lib/arf/wire/stream/state.rb', line 15 def close @code = :closed end |
#close_local ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/arf/wire/stream/state.rb', line 19 def close_local @code = case @code when :open then :half_closed_local when :half_closed_local then :half_closed_local when :half_closed_remote, :closed then :closed end end |
#close_remote ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/arf/wire/stream/state.rb', line 27 def close_remote @code = case @code when :open then :half_closed_remote when :half_closed_local, :closed then :closed when :half_closed_remote then :half_closed_remote end end |
#closed? ⇒ Boolean
35 |
# File 'lib/arf/wire/stream/state.rb', line 35 def closed? = (@code == :closed) |
#local_closed? ⇒ Boolean
37 |
# File 'lib/arf/wire/stream/state.rb', line 37 def local_closed? = (@code == :half_closed_local) |
#may_receive_data? ⇒ Boolean
46 47 48 49 50 51 |
# File 'lib/arf/wire/stream/state.rb', line 46 def may_receive_data? raise @error if @error raise ClosedStreamError if closed? || remote_closed? true end |
#may_reset_stream? ⇒ Boolean
39 40 41 42 43 44 |
# File 'lib/arf/wire/stream/state.rb', line 39 def may_reset_stream? raise @error if @error raise ClosedStreamError if closed? true end |
#may_send_data? ⇒ Boolean
60 61 62 63 64 65 |
# File 'lib/arf/wire/stream/state.rb', line 60 def may_send_data? raise @error if @error raise ClosedStreamError if closed? || local_closed? true end |
#may_send_reset_stream? ⇒ Boolean
53 54 55 56 57 58 |
# File 'lib/arf/wire/stream/state.rb', line 53 def may_send_reset_stream? raise @error if @error raise ClosedStreamError if closed? || local_closed? true end |
#remote_closed? ⇒ Boolean
36 |
# File 'lib/arf/wire/stream/state.rb', line 36 def remote_closed? = (@code == :half_closed_remote) |