Class: RSocks::StateMachine

Inherits:
Object
  • Object
show all
Defined in:
lib/r_socks/state_machine.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStateMachine

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

Returns:

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

Returns:

  • (Boolean)


23
24
25
# File 'lib/r_socks/state_machine.rb', line 23

def connect?
  current_state == :connect
end

#handshake?Boolean

Returns:

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

Returns:

  • (Boolean)


27
28
29
# File 'lib/r_socks/state_machine.rb', line 27

def start?
  current_state == :start
end

#state_changedObject



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