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) ⇒ State

Returns a new instance of State.



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

def initialize(stateable)
  @stateable = stateable
end

Instance Attribute Details

#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

#stateObject



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

def state
  self.class.to_s
end

#transition_to(state_class) ⇒ Object



8
9
10
# File 'lib/state_pattern/state.rb', line 8

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