Sha256: 86752b40eab0725e6150c77e2939482db67827c9af058ee91f897b207e5b6f97

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

module LanguageServer
  module Protocol
    module Interface
      class DocumentFilter
        def initialize(language: nil, scheme: nil, pattern: nil)
          @attributes = {}

          @attributes[:language] = language if language
          @attributes[:scheme] = scheme if scheme
          @attributes[:pattern] = pattern if pattern

          @attributes.freeze
        end

        #
        # A language id, like `typescript`.
        #
        # @return [string]
        def language
          attributes.fetch(:language)
        end

        #
        # A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
        #
        # @return [string]
        def scheme
          attributes.fetch(:scheme)
        end

        #
        # A glob pattern, like `*.{ts,js}`.
        #
        # @return [string]
        def pattern
          attributes.fetch(:pattern)
        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

3 entries across 3 versions & 1 rubygems

Version Path
language_server-protocol-3.12.0.0 lib/language_server/protocol/interface/document_filter.rb
language_server-protocol-3.7.0.0 lib/language_server/protocol/interface/document_filter.rb
language_server-protocol-0.5.0 lib/language_server/protocol/interface/document_filter.rb