Sha256: 869307f5c99588bd78ea9dc036fae8e17f9b4905024e5f58497da55f6eea03d6

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

module LanguageServer
  module Protocol
    module Interface
      class ResponseMessage < Message
        def initialize(jsonrpc:, id:, result: nil, error: nil)
          @attributes = {}

          @attributes[:id] = id
          @attributes[:result] = result if result
          @attributes[:error] = error if error

          @attributes.freeze
        end

        #
        # The request id.
        #
        # @return [string | number]
        def id
          attributes.fetch(:id)
        end

        #
        # The result of a request. This can be omitted in
        # the case of an error.
        #
        # @return [any]
        def result
          attributes.fetch(:result)
        end

        #
        # The error object in case a request fails.
        #
        # @return [ResponseError<any>]
        def error
          attributes.fetch(:error)
        end

        attr_reader :attributes

        def to_hash
          attributes
        end

        def to_json(*args)
          to_hash.to_json(*args)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
language_server-protocol-3.14.0.1 lib/language_server/protocol/interface/response_message.rb
language_server-protocol-3.14.0.0 lib/language_server/protocol/interface/response_message.rb
language_server-protocol-3.12.0.0 lib/language_server/protocol/interface/response_message.rb
language_server-protocol-3.7.0.0 lib/language_server/protocol/interface/response_message.rb
language_server-protocol-0.5.0 lib/language_server/protocol/interface/response_message.rb