when iterating over tree. Much cleaner, less hokuspukus methods that are noops Mom is coming back out, but not linked yet
36 lines
557 B
Ruby
36 lines
557 B
Ruby
module Common
|
|
#extracted to resuse
|
|
module Statements
|
|
attr_reader :statements
|
|
def initialize(statements)
|
|
@statements = statements
|
|
end
|
|
|
|
def empty?
|
|
@statements.empty?
|
|
end
|
|
def single?
|
|
@statements.length == 1
|
|
end
|
|
def first
|
|
@statements.first
|
|
end
|
|
def last
|
|
@statements.last
|
|
end
|
|
def length
|
|
@statements.length
|
|
end
|
|
def [](i)
|
|
@statements[i]
|
|
end
|
|
def <<(o)
|
|
@statements << o
|
|
self
|
|
end
|
|
def add_array(a)
|
|
@statements += a
|
|
end
|
|
end
|
|
end
|