Class: LanguageServer::Protocol::Interface::RelativePattern

Inherits:
Object
  • Object
show all
Defined in:
lib/language_server/protocol/interface/relative_pattern.rb

Overview

A relative pattern is a helper to construct glob patterns that are matched relatively to a base URI. The common value for a baseUri is a workspace folder root, but it can be another absolute URI as well.

Since:

  • 3.17.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_uri:, pattern:) ⇒ RelativePattern

Returns a new instance of RelativePattern.

Since:

  • 3.17.0



12
13
14
15
16
17
18
19
# File 'lib/language_server/protocol/interface/relative_pattern.rb', line 12

def initialize(base_uri:, pattern:)
  @attributes = {}

  @attributes[:baseUri] = base_uri
  @attributes[:pattern] = pattern

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Since:

  • 3.17.0



38
39
40
# File 'lib/language_server/protocol/interface/relative_pattern.rb', line 38

def attributes
  @attributes
end

Instance Method Details

#base_uriWorkspaceFolder | URI

A workspace folder or a base URI to which this pattern will be matched against relatively.

Returns:

Since:

  • 3.17.0



26
27
28
# File 'lib/language_server/protocol/interface/relative_pattern.rb', line 26

def base_uri
  attributes.fetch(:baseUri)
end

#patternPattern

The actual glob pattern;

Returns:

  • (Pattern)

Since:

  • 3.17.0



34
35
36
# File 'lib/language_server/protocol/interface/relative_pattern.rb', line 34

def pattern
  attributes.fetch(:pattern)
end

#to_hashObject

Since:

  • 3.17.0



40
41
42
# File 'lib/language_server/protocol/interface/relative_pattern.rb', line 40

def to_hash
  attributes
end

#to_json(*args) ⇒ Object

Since:

  • 3.17.0



44
45
46
# File 'lib/language_server/protocol/interface/relative_pattern.rb', line 44

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