2017-09-06 11:33:46 +02:00
|
|
|
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
|
2017-09-06 11:51:24 +02:00
|
|
|
def last
|
|
|
|
@statements.last
|
|
|
|
end
|
2017-09-06 11:33:46 +02:00
|
|
|
def length
|
|
|
|
@statements.length
|
|
|
|
end
|
2017-09-06 11:51:24 +02:00
|
|
|
def [](i)
|
|
|
|
@statements[i]
|
|
|
|
end
|
2018-03-11 11:41:15 +01:00
|
|
|
def <<(o)
|
|
|
|
@statements << o
|
2018-03-15 08:16:56 +01:00
|
|
|
self
|
2018-03-11 11:41:15 +01:00
|
|
|
end
|
2017-09-06 11:33:46 +02:00
|
|
|
def collect(arr)
|
|
|
|
@statements.each { |s| s.collect(arr) }
|
|
|
|
super
|
|
|
|
end
|
2018-03-12 13:43:26 +01:00
|
|
|
def add_array(a)
|
|
|
|
@statements += a
|
|
|
|
end
|
2017-09-06 11:33:46 +02:00
|
|
|
end
|
|
|
|
end
|