Sha256: ad950777b62c35294e21fec0fe72ace1afb38e24e1d1ddce9fd79415a3d1dcd0
Contents?: true
Size: 816 Bytes
Versions: 5
Compression:
Stored size: 816 Bytes
Contents
module Dentaku module AST class Negation < Arithmetic def initialize(node) @node = node unless valid_node?(node) raise NodeError.new(:numeric, left.type, :left), "#{self.class} requires numeric operands" end end def operator :* end def value(context = {}) cast(@node.value(context)) * -1 end def type :numeric end def self.arity 1 end def self.right_associative? true end def self.precedence 40 end def dependencies(context = {}) @node.dependencies(context) end private def valid_node?(node) node && (node.dependencies.any? || node.type == :numeric) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems