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.
-
#stateful ⇒ Object
readonly
Returns the value of attribute stateful.
Class Method Summary collapse
Instance Method Summary collapse
- #enter ⇒ Object
- #exit ⇒ Object
-
#initialize(stateful, previous_state) ⇒ State
constructor
A new instance of State.
- #transition_to(state_class) ⇒ Object
Constructor Details
#initialize(stateful, previous_state) ⇒ State
Returns a new instance of State.
4 5 6 7 8 |
# File 'lib/state_pattern/state.rb', line 4 def initialize(stateful, previous_state) @stateful = stateful @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 |
#stateful ⇒ Object (readonly)
Returns the value of attribute stateful.
3 4 5 |
# File 'lib/state_pattern/state.rb', line 3 def stateful @stateful end |
Class Method Details
.state_methods ⇒ Object
10 11 12 |
# File 'lib/state_pattern/state.rb', line 10 def self.state_methods public_instance_methods - State.public_instance_methods end |
Instance Method Details
#enter ⇒ Object
18 19 |
# File 'lib/state_pattern/state.rb', line 18 def enter end |
#exit ⇒ Object
21 22 |
# File 'lib/state_pattern/state.rb', line 21 def exit end |
#transition_to(state_class) ⇒ Object
14 15 16 |
# File 'lib/state_pattern/state.rb', line 14 def transition_to(state_class) @stateful.transition_to(state_class) end |