Class: Chelsy::For
- Defined in:
- lib/chelsy/ast.rb
Overview
This class represents for
iteration statement.
Instance Attribute Summary collapse
-
#init ⇒ Object
readonly
Returns the value of attribute init.
-
#loop ⇒ Object
readonly
Returns the value of attribute loop.
Attributes inherited from Iteration
Attributes inherited from Element
Instance Method Summary collapse
-
#initialize(init_stmt = nil, condition_expr = nil, loop_expr = nil, body_stmt = nil, **rest) {|Chelsy::Block| ... } ⇒ For
constructor
Initialize iteration statement with its condition and iteration body statement.
Constructor Details
#initialize(init_stmt = nil, condition_expr = nil, loop_expr = nil, body_stmt = nil, **rest) {|Chelsy::Block| ... } ⇒ For
Initialize iteration statement with its condition and iteration body statement. You can pass an optional code block which takes Block instance can be used to construct iteration body statements.
1067 1068 1069 1070 1071 1072 |
# File 'lib/chelsy/ast.rb', line 1067 def initialize(init_stmt=nil, condition_expr=nil, loop_expr=nil, body_stmt=nil, **rest) @init = Syntax::BlockItem::ensure(init_stmt) if init_stmt @loop = Syntax::Expr.ensure(loop_expr) if loop_expr super condition_expr, body_stmt, **rest end |
Instance Attribute Details
#init ⇒ Object (readonly)
Returns the value of attribute init.
1062 1063 1064 |
# File 'lib/chelsy/ast.rb', line 1062 def init @init end |
#loop ⇒ Object (readonly)
Returns the value of attribute loop.
1062 1063 1064 |
# File 'lib/chelsy/ast.rb', line 1062 def loop @loop end |