Class: Chelsy::Operator::Conditional

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

Overview

Ternary conditional

Instance Attribute Summary collapse

Attributes inherited from Element

#fragments, #post_fragments

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

precedence

Constructor Details

#initialize(condition, then_expr, else_expr, **rest) ⇒ Conditional

Returns a new instance of Conditional.



579
580
581
582
583
584
585
# File 'lib/chelsy/ast.rb', line 579

def initialize(condition, then_expr, else_expr, **rest)
  @condition = Syntax::Expr.ensure(condition)
  @then = Syntax::Expr.ensure(then_expr)
  @else = Syntax::Expr.ensure(else_expr)

  super **rest
end

Instance Attribute Details

#conditionObject (readonly)

Returns the value of attribute condition.



575
576
577
# File 'lib/chelsy/ast.rb', line 575

def condition
  @condition
end

#elseObject (readonly)

Returns the value of attribute else.



575
576
577
# File 'lib/chelsy/ast.rb', line 575

def else
  @else
end

#thenObject (readonly)

Returns the value of attribute then.



575
576
577
# File 'lib/chelsy/ast.rb', line 575

def then
  @then
end

Class Method Details

.operatorObject



577
# File 'lib/chelsy/ast.rb', line 577

def self.operator; :"?:" end