rubyx/lib/vool/statements/while_statement.rb
2017-04-08 12:10:42 +03:00

24 lines
488 B
Ruby

module Vool
class WhileStatement < Statement
attr_reader :condition , :statements
def initialize( condition , statements )
@condition = condition
@statements = statements
simplify_condition
end
def simplify_condition
return unless @condition.is_a?(ScopeStatement)
@condition = @condition.first if @condition.single?
end
def collect(arr)
@condition.collect(arr)
@statements.collect(arr)
super
end
end
end