Sha256: 5898dbffb72db214aff828518d39faf7465ea5c8e6fea14e7f004569139897c9

Contents?: true

Size: 475 Bytes

Versions: 34

Compression:

Stored size: 475 Bytes

Contents

# frozen_string_literal: true

class Code
  class Node
    class UnaryMinus < Node
      def initialize(parsed)
        return if parsed.blank?

        @operator = parsed.delete(:operator).presence
        @right = Node::Statement.new(parsed.delete(:right).presence)
      end

      def evaluate(**args)
        if @right
          @right.evaluate(**args).call(operator: @operator, **args)
        else
          Object::Nothing.new
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
code-ruby-1.2.5 lib/code/node/unary_minus.rb
code-ruby-1.2.4 lib/code/node/unary_minus.rb
code-ruby-1.2.3 lib/code/node/unary_minus.rb
code-ruby-1.2.2 lib/code/node/unary_minus.rb
code-ruby-1.2.1 lib/code/node/unary_minus.rb
code-ruby-1.1.3 lib/code/node/unary_minus.rb
code-ruby-1.1.1 lib/code/node/unary_minus.rb
code-ruby-1.1.0 lib/code/node/unary_minus.rb
code-ruby-1.0.0 lib/code/node/unary_minus.rb
code-ruby-0.15.16 lib/code/node/unary_minus.rb
code-ruby-0.15.15 lib/code/node/unary_minus.rb
code-ruby-0.15.14 lib/code/node/unary_minus.rb
code-ruby-0.15.13 lib/code/node/unary_minus.rb
code-ruby-0.15.12 lib/code/node/unary_minus.rb
code-ruby-0.15.11 lib/code/node/unary_minus.rb
code-ruby-0.15.10 lib/code/node/unary_minus.rb
code-ruby-0.15.9 lib/code/node/unary_minus.rb
code-ruby-0.15.8 lib/code/node/unary_minus.rb
code-ruby-0.15.7 lib/code/node/unary_minus.rb
code-ruby-0.15.6 lib/code/node/unary_minus.rb