Sha256: fa44f1c418a64df81baa7269ed05c6e5e6dc9ae359f7db952916cc015121b5e3

Contents?: true

Size: 874 Bytes

Versions: 6

Compression:

Stored size: 874 Bytes

Contents

require 'dentaku/exceptions'

module Dentaku
  module AST
    class CaseConditional < Node
      attr_reader :when,
                  :then

      def self.min_param_count
        2
      end

      def self.max_param_count
        2
      end

      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

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

      def accept(visitor)
        visitor.visit_case_conditional(self)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
dentaku-3.5.4 lib/dentaku/ast/case/case_conditional.rb
dentaku-3.5.3 lib/dentaku/ast/case/case_conditional.rb
dentaku-3.5.2 lib/dentaku/ast/case/case_conditional.rb
dentaku_zevo-3.5.2 lib/dentaku/ast/case/case_conditional.rb
dentaku-3.5.1 lib/dentaku/ast/case/case_conditional.rb
dentaku-3.5.0 lib/dentaku/ast/case/case_conditional.rb