Sha256: a049fdafee11705d28533f689358a0a7ac7b211275b624ecbbf4a3510d0ec52d

Contents?: true

Size: 1.35 KB

Versions: 10

Compression:

Stored size: 1.35 KB

Contents

module Steep
  module Server
    class WorkDoneProgress
      attr_reader :sender, :guid, :percentage

      def initialize(guid, &block)
        @sender = block
        @guid = guid
        @percentage = 0
      end

      def begin(title, message = nil, request_id:)
        sender.call(
          {
            id: request_id,
            method: "window/workDoneProgress/create",
            params: { token: guid }
          }
        )

        value = { kind: "begin", cancellable: false, title: title, percentage: percentage }
        value[:message] = message if message

        sender.call(
          {
            method: "$/progress",
            params: { token: guid, value: value }
          }
        )

        self
      end

      def report(percentage, message = nil)
        @percentage = percentage
        value = { kind: "report", percentage: percentage }
        value[:message] = message if message

        sender.call(
          {
            method: "$/progress",
            params: { token: guid, value: value }
          }
        )

        self
      end

      def end(message = nil)
        value = { kind: "end" }
        value[:message] = message if message

        sender.call(
          {
            method: "$/progress",
            params: { token: guid, value: value }
          }
        )

        self
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
steep-1.9.1 lib/steep/server/work_done_progress.rb
steep-1.9.0 lib/steep/server/work_done_progress.rb
steep-1.9.0.dev.2 lib/steep/server/work_done_progress.rb
steep-1.9.0.dev.1 lib/steep/server/work_done_progress.rb
steep-1.8.3 lib/steep/server/work_done_progress.rb
steep-1.8.2 lib/steep/server/work_done_progress.rb
steep-1.8.1 lib/steep/server/work_done_progress.rb
steep-1.8.0 lib/steep/server/work_done_progress.rb
steep-1.8.0.pre.2 lib/steep/server/work_done_progress.rb
steep-1.8.0.pre.1 lib/steep/server/work_done_progress.rb