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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_uri:, pattern:) ⇒ RelativePattern

Returns a new instance of RelativePattern.



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

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

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

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



36
37
38
# File 'lib/language_server/protocol/interface/relative_pattern.rb', line 36

def attributes
  @attributes
end

Instance Method Details

#base_uristring | WorkspaceFolder

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

Returns:



24
25
26
# File 'lib/language_server/protocol/interface/relative_pattern.rb', line 24

def base_uri
  attributes.fetch(:baseUri)
end

#patternstring

The actual glob pattern;

Returns:

  • (string)


32
33
34
# File 'lib/language_server/protocol/interface/relative_pattern.rb', line 32

def pattern
  attributes.fetch(:pattern)
end

#to_hashObject



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

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



42
43
44
# File 'lib/language_server/protocol/interface/relative_pattern.rb', line 42

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