Class: StatePattern::State
- Inherits:
-
Object
- Object
- StatePattern::State
- Defined in:
- lib/state_pattern/state.rb
Instance Attribute Summary collapse
-
#previous_state ⇒ Object
readonly
Returns the value of attribute previous_state.
-
#stateable ⇒ Object
readonly
Returns the value of attribute stateable.
Instance Method Summary collapse
- #enter ⇒ Object
- #exit ⇒ Object
-
#initialize(stateable, previous_state) ⇒ State
constructor
A new instance of State.
- #transition_to(state_class) ⇒ Object
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_state ⇒ Object (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 |
#stateable ⇒ Object (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
#enter ⇒ Object
14 15 |
# File 'lib/state_pattern/state.rb', line 14 def enter end |
#exit ⇒ Object
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 |