Class: StatePattern::State

Inherits:
Object
  • Object
show all
Defined in:
lib/state_pattern/state.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stateable, previous_state) ⇒ State

Returns a new instance of State.



4
5
6
7
8
# File 'lib/state_pattern/state.rb', line 4

def initialize(stateable, previous_state)
  @stateable = stateable
  @previous_state = previous_state
  enter
end

Instance Attribute Details

#previous_stateObject (readonly)

Returns the value of attribute previous_state.



3
4
5
# File 'lib/state_pattern/state.rb', line 3

def previous_state
  @previous_state
end

#stateableObject (readonly)

Returns the value of attribute stateable.



3
4
5
# File 'lib/state_pattern/state.rb', line 3

def stateable
  @stateable
end

Instance Method Details

#enterObject



14
15
# File 'lib/state_pattern/state.rb', line 14

def enter
end

#exitObject



17
18
# File 'lib/state_pattern/state.rb', line 17

def exit
end

#transition_to(state_class) ⇒ Object



10
11
12
# File 'lib/state_pattern/state.rb', line 10

def transition_to(state_class)
  @stateable.transition_to(state_class)
end