rubyx/lib/common/statements.rb
Torsten Ruger f7aac1d1a4 polish docs
and a bit of code style
2018-03-11 16:11:15 +05:30

36 lines
581 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
end
def collect(arr)
@statements.each { |s| s.collect(arr) }
super
end
end
end