Sha256: 92909bbfbc24417248a9a24d7d2cd316335195b325848a810e47618bae82723e

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

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

          @attributes[:jsonrpc] = jsonrpc
          @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 member is REQUIRED on success.
        # This member MUST NOT exist if there was an error invoking the method.
        #
        # @return [string | number | boolean | object]
        def result
          attributes.fetch(:result)
        end

        #
        # The error object in case a request fails.
        #
        # @return [ResponseError]
        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

4 entries across 4 versions & 1 rubygems

Version Path
language_server-protocol-3.16.0.0 lib/language_server/protocol/interface/response_message.rb
language_server-protocol-3.15.0.2 lib/language_server/protocol/interface/response_message.rb
language_server-protocol-3.15.0.1 lib/language_server/protocol/interface/response_message.rb
language_server-protocol-3.15.0.0 lib/language_server/protocol/interface/response_message.rb