Sha256: 7ff8c796d4a93070a2910dd4928c451542fac4623bfe54174712a565a33f9fb3
Contents?: true
Size: 984 Bytes
Versions: 5
Compression:
Stored size: 984 Bytes
Contents
require_relative '../function' module Dentaku module AST class If < Function attr_reader :predicate, :left, :right def self.min_param_count 3 end def self.max_param_count 3 end def initialize(predicate, left, right) @predicate = predicate @left = left @right = right end def value(context = {}) predicate.value(context) ? left.value(context) : right.value(context) end def node_type :condition end def type left.type end def dependencies(context = {}) deps = predicate.dependencies(context) if deps.empty? predicate.value(context) ? left.dependencies(context) : right.dependencies(context) else (deps + left.dependencies(context) + right.dependencies(context)).uniq end end end end end Dentaku::AST::Function.register_class(:if, Dentaku::AST::If)
Version data entries
5 entries across 5 versions & 1 rubygems