Sha256: 32a9336dcb7691f24a2a8329df3d9f16457cc72d42682912917dd1c4fab2ff90

Contents?: true

Size: 721 Bytes

Versions: 4

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true

class Code
  class Node
    class CallArgument < Node
      def initialize(parsed)
        return if parsed.blank?
        @value = Node::Code.new(parsed.delete(:value).presence)
        @name = parsed.delete(:name).presence
      end

      def evaluate(**args)
        if @name
          Object::Argument.new(
            @value&.evaluate(**args) || Object::Nothing.new,
            name:
          )
        else
          Object::Argument.new(@value&.evaluate(**args) || Object::Nothing.new)
        end
      end

      def keyword?
        !!@name
      end

      def regular?
        !keyword?
      end

      def name
        Object::String.new(@name)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
code-ruby-0.13.1 lib/code/node/call_argument.rb
code-ruby-0.13.0 lib/code/node/call_argument.rb
code-ruby-0.12.0 lib/code/node/call_argument.rb
code-ruby-0.11.0 lib/code/node/call_argument.rb