Module: LibWebSocket::Stateful

Included in:
Message
Defined in:
lib/libwebsocket/stateful.rb

Overview

Base class for all classes with states

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stateObject

Returns the value of attribute state.



5
6
7
# File 'lib/libwebsocket/stateful.rb', line 5

def state
  @state
end

Instance Method Details

#doneObject

Change state to ‘done’



13
14
15
16
# File 'lib/libwebsocket/stateful.rb', line 13

def done
  @state = 'done'
  true
end

#done?Boolean

Check if current state is done

Returns:

  • (Boolean)


19
20
21
# File 'lib/libwebsocket/stateful.rb', line 19

def done?
  @state == 'done'
end

#state?(val) ⇒ Boolean

Return true if current state match given state

Returns:

  • (Boolean)


8
9
10
# File 'lib/libwebsocket/stateful.rb', line 8

def state?(val)
  @state == val
end