Sha256: 8449c4b3da0d8cb6cd8499cdaf5f83a98104979ba2189858d91eb39605aaf0b4

Contents?: true

Size: 1019 Bytes

Versions: 1

Compression:

Stored size: 1019 Bytes

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_json(*args)
          attributes.to_json(*args)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
language_server-protocol-0.4.0 lib/language_server/protocol/interface/response_message.rb