Class: RSocks::StateMachine
- Inherits:
-
Object
- Object
- RSocks::StateMachine
- Defined in:
- lib/r_socks/state_machine.rb
Instance Attribute Summary collapse
-
#current_state ⇒ Object
readonly
Returns the value of attribute current_state.
Instance Method Summary collapse
- #auth! ⇒ Object
- #auth? ⇒ Boolean
- #connect! ⇒ Object
- #connect? ⇒ Boolean
- #handshake? ⇒ Boolean
-
#initialize ⇒ StateMachine
constructor
A new instance of StateMachine.
- #start! ⇒ Object
- #start? ⇒ Boolean
- #state_changed ⇒ Object
Constructor Details
#initialize ⇒ StateMachine
Returns a new instance of StateMachine.
9 10 11 12 13 |
# File 'lib/r_socks/state_machine.rb', line 9 def initialize @max = 3 @state_num = 0 @current_state = RSocks::STATE_LIST[@state_num] end |
Instance Attribute Details
#current_state ⇒ Object (readonly)
Returns the value of attribute current_state.
7 8 9 |
# File 'lib/r_socks/state_machine.rb', line 7 def current_state @current_state end |
Instance Method Details
#auth! ⇒ Object
31 32 33 34 |
# File 'lib/r_socks/state_machine.rb', line 31 def auth! @state_num = 1 @current_state = RSocks::STATE_LIST[@state_num] end |
#auth? ⇒ Boolean
19 20 21 |
# File 'lib/r_socks/state_machine.rb', line 19 def auth? current_state == :auth end |
#connect! ⇒ Object
36 37 38 39 |
# File 'lib/r_socks/state_machine.rb', line 36 def connect! @state_num = 2 @current_state = RSocks::STATE_LIST[@state_num] end |
#connect? ⇒ Boolean
23 24 25 |
# File 'lib/r_socks/state_machine.rb', line 23 def connect? current_state == :connect end |
#handshake? ⇒ Boolean
15 16 17 |
# File 'lib/r_socks/state_machine.rb', line 15 def handshake? current_state == :handshake end |
#start! ⇒ Object
41 42 43 44 |
# File 'lib/r_socks/state_machine.rb', line 41 def start! @state_num = 3 @current_state = RSocks::STATE_LIST[@state_num] end |
#start? ⇒ Boolean
27 28 29 |
# File 'lib/r_socks/state_machine.rb', line 27 def start? current_state == :start end |
#state_changed ⇒ Object
46 47 48 49 |
# File 'lib/r_socks/state_machine.rb', line 46 def state_changed @state_num += 1 unless @state_num >= @max @current_state = RSocks::STATE_LIST[@state_num] end |