Class: Nay::State

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

Overview

Basic stack implementation for storing a basic state machine flow.

Constant Summary collapse

DEFAULT =
:default

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeState

Returns a new instance of State.



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

def initialize
  @stack = []
end

Instance Attribute Details

#stackObject (readonly)

Returns the value of attribute stack.



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

def stack
  @stack
end

Instance Method Details

#currentObject



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

def current
  stack.last || DEFAULT
end

#popObject



22
23
24
# File 'lib/nay/state.rb', line 22

def pop
  stack.pop
end

#push(state) ⇒ Object



18
19
20
# File 'lib/nay/state.rb', line 18

def push(state)
  stack.push(state)
end