Class: Arf::Wire::Stream::State

Inherits:
Object
  • Object
show all
Defined in:
lib/arf/wire/stream/state.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeState

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

#codeObject (readonly)

Returns the value of attribute code.



7
8
9
# File 'lib/arf/wire/stream/state.rb', line 7

def code
  @code
end

#errorObject

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

#closeObject



15
16
17
# File 'lib/arf/wire/stream/state.rb', line 15

def close
  @code = :closed
end

#close_localObject



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_remoteObject



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

Returns:

  • (Boolean)


35
# File 'lib/arf/wire/stream/state.rb', line 35

def closed? = (@code == :closed)

#local_closed?Boolean

Returns:

  • (Boolean)


37
# File 'lib/arf/wire/stream/state.rb', line 37

def local_closed? = (@code == :half_closed_local)

#may_receive_data?Boolean

Returns:

  • (Boolean)

Raises:



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

Returns:

  • (Boolean)

Raises:



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

Returns:

  • (Boolean)

Raises:



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

Returns:

  • (Boolean)

Raises:



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

Returns:

  • (Boolean)


36
# File 'lib/arf/wire/stream/state.rb', line 36

def remote_closed? = (@code == :half_closed_remote)