Sha256: b9de595fffe27defcd0adf61a86cdd39d8f091fe168bc5b40592c58cfe3c4fbf

Contents?: true

Size: 983 Bytes

Versions: 29

Compression:

Stored size: 983 Bytes

Contents

# frozen_string_literal: true

class Code
  class Object
    class IdentifierList < List
      def call(**args)
        operator = args.fetch(:operator, nil)
        arguments = args.fetch(:arguments, List.new)
        context = args.fetch(:context)
        value = arguments.code_first

        case operator.to_s
        when /=$/
          sig(args) { Object }

          context = context.lookup!(raw.first)

          context =
            raw[..-2].reduce(context) do |context, identifier|
              context.code_fetch(identifier)
            end

          context.code_set(
            raw.last,
            if operator == "="
              value
            else
              context.fetch(raw.last).call(
                **args,
                operator: operator.chop,
                arguments: List.new([value])
              )
            end
          )

          context.code_fetch(raw.last)
        else
          super
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
code-ruby-0.14.9 lib/code/object/identifier_list.rb
code-ruby-0.14.8 lib/code/object/identifier_list.rb
code-ruby-0.14.6 lib/code/object/identifier_list.rb
code-ruby-0.14.5 lib/code/object/identifier_list.rb
code-ruby-0.14.4 lib/code/object/identifier_list.rb
code-ruby-0.14.3 lib/code/object/identifier_list.rb
code-ruby-0.14.2 lib/code/object/identifier_list.rb
code-ruby-0.14.1 lib/code/object/identifier_list.rb
code-ruby-0.14.0 lib/code/object/identifier_list.rb