rubyx/lib/common/statements.rb

39 lines
633 B
Ruby
Raw Normal View History

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 12:51:24 +03:00
def last
@statements.last
end
def length
@statements.length
end
2017-09-06 12:51:24 +03:00
def [](i)
@statements[i]
end
2018-03-11 16:11:15 +05:30
def <<(o)
@statements << o
end
def collect(arr)
@statements.each { |s| s.collect(arr) }
super
end
2018-03-12 18:13:26 +05:30
def add_array(a)
@statements += a
end
end
end