Class: Graft::Stack

Inherits:
Array
  • Object
show all
Defined in:
lib/graft/stack.rb

Instance Method Summary collapse

Instance Method Details

#call(env = {}) ⇒ Object



5
6
7
# File 'lib/graft/stack.rb', line 5

def call(env = {})
  head.call(tail, env)
end

#headObject



9
10
11
12
13
# File 'lib/graft/stack.rb', line 9

def head
  # TODO: raise EmptyStackError?

  first
end

#tailObject



15
16
17
18
19
20
21
22
# File 'lib/graft/stack.rb', line 15

def tail
  tail = self[1..size]

  # TODO: raise EmptyStackError?
  return Stack.new if tail.nil?

  Stack.new(tail)
end