Class: Chelsy::Iteration Abstract
Overview
This class is abstract.
Subclass to implement a custom iteration class.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
Attributes inherited from Element
Instance Method Summary collapse
-
#initialize(condition_expr = nil, body_stmt = nil, **rest) {|Chelsy::Block| ... } ⇒ Iteration
constructor
Initialize iteration statement with its condition and iteration body statement.
Constructor Details
#initialize(condition_expr = nil, body_stmt = nil, **rest) {|Chelsy::Block| ... } ⇒ Iteration
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.
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 |
# File 'lib/chelsy/ast.rb', line 1024 def initialize(condition_expr=nil, body_stmt=nil, **rest) @condition = Syntax::Expr.ensure(condition_expr) if condition_expr if block_given? @body = Block.new yield @body elsif body_stmt @body = Syntax::Stmt.ensure(body_stmt) else raise ArgumentError, "missing body statement" end super **rest end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
1014 1015 1016 |
# File 'lib/chelsy/ast.rb', line 1014 def body @body end |
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
1014 1015 1016 |
# File 'lib/chelsy/ast.rb', line 1014 def condition @condition end |