Class: Dentaku::AST::CaseConditional

Inherits:
Node
  • Object
show all
Defined in:
lib/dentaku/ast/case/case_conditional.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

arity, peek, precedence

Constructor Details

#initialize(when_statement, then_statement) ⇒ CaseConditional

Returns a new instance of CaseConditional.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dentaku/ast/case/case_conditional.rb', line 9

def initialize(when_statement, then_statement)
  @when = when_statement
  unless @when.is_a?(AST::CaseWhen)
    raise ParseError.for(:node_invalid), 'Expected first argument to be a CaseWhen'
  end

  @then = then_statement
  unless @then.is_a?(AST::CaseThen)
    raise ParseError.for(:node_invalid), 'Expected second argument to be a CaseThen'
  end
end

Instance Attribute Details

#thenObject (readonly)

Returns the value of attribute then.



6
7
8
# File 'lib/dentaku/ast/case/case_conditional.rb', line 6

def then
  @then
end

#whenObject (readonly)

Returns the value of attribute when.



6
7
8
# File 'lib/dentaku/ast/case/case_conditional.rb', line 6

def when
  @when
end

Instance Method Details

#dependencies(context = {}) ⇒ Object



21
22
23
# File 'lib/dentaku/ast/case/case_conditional.rb', line 21

def dependencies(context = {})
  @when.dependencies(context) + @then.dependencies(context)
end