Class: Chelsy::If

Inherits:
Stmt show all
Defined in:
lib/chelsy/ast.rb

Overview

=== 6.8.4.1 The if statement

Instance Attribute Summary collapse

Attributes inherited from Element

#fragments, #post_fragments

Instance Method Summary collapse

Constructor Details

#initialize(condition_expr, then_stmt, else_stmt = nil, **rest) ⇒ If

Returns a new instance of If.



972
973
974
975
976
977
978
# File 'lib/chelsy/ast.rb', line 972

def initialize(condition_expr, then_stmt, else_stmt=nil, **rest)
  @condition = Syntax::Expr.ensure(condition_expr)
  @then = Syntax::Stmt::ensure(then_stmt)
  @else = Syntax::Stmt::ensure(else_stmt) if else_stmt

  super **rest
end

Instance Attribute Details

#conditionObject (readonly)

Returns the value of attribute condition.



970
971
972
# File 'lib/chelsy/ast.rb', line 970

def condition
  @condition
end

#elseObject (readonly)

Returns the value of attribute else.



970
971
972
# File 'lib/chelsy/ast.rb', line 970

def else
  @else
end

#thenObject (readonly)

Returns the value of attribute then.



970
971
972
# File 'lib/chelsy/ast.rb', line 970

def then
  @then
end