Sha256: 5d805e54dd9dc274c2644e000a0ff783dc08801104e52b793bf99a452b36c920
Contents?: true
Size: 1.02 KB
Versions: 4
Compression:
Stored size: 1.02 KB
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 args [predicate, left, 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
4 entries across 4 versions & 2 rubygems