Class: Melbourne::AST::While

Inherits:
Node
  • Object
show all
Defined in:
lib/melbourne/ast/control_flow.rb

Overview

A while statement as in:

i += 1 while go_on?

Direct Known Subclasses

Until

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#ascii_graph

Constructor Details

#initialize(line, condition, body, check_first) ⇒ While

Returns a new instance of While.



206
207
208
209
210
211
# File 'lib/melbourne/ast/control_flow.rb', line 206

def initialize(line, condition, body, check_first)
  @line = line
  @condition = condition
  @body = body || Nil.new(line)
  @check_first = check_first
end

Instance Attribute Details

#bodyObject

The body of the while statement (the code that is executed if the condition evaluates to true)



200
201
202
# File 'lib/melbourne/ast/control_flow.rb', line 200

def body
  @body
end

#check_firstObject

Whether to check the while statement’s condition before or after ths code in the body is executed



204
205
206
# File 'lib/melbourne/ast/control_flow.rb', line 204

def check_first
  @check_first
end

#conditionObject

The condition of the while statement



196
197
198
# File 'lib/melbourne/ast/control_flow.rb', line 196

def condition
  @condition
end