Class: LanguageServer::FileStore::FilePath

Inherits:
Object
  • Object
show all
Defined in:
lib/language_server/file_store.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(remote_root:, local_root:, local_path:) ⇒ FilePath

Returns a new instance of FilePath.



16
17
18
19
20
# File 'lib/language_server/file_store.rb', line 16

def initialize(remote_root:, local_root:, local_path:)
  @remote_root = remote_root
  @local_root = local_root
  @local_path = local_path
end

Instance Attribute Details

#local_pathObject (readonly)

Returns the value of attribute local_path.



14
15
16
# File 'lib/language_server/file_store.rb', line 14

def local_path
  @local_path
end

#local_rootObject (readonly)

Returns the value of attribute local_root.



14
15
16
# File 'lib/language_server/file_store.rb', line 14

def local_root
  @local_root
end

#remote_rootObject (readonly)

Returns the value of attribute remote_root.



14
15
16
# File 'lib/language_server/file_store.rb', line 14

def remote_root
  @remote_root
end

Class Method Details

.from_remote_uri(remote_root:, local_root:, remote_uri:) ⇒ Object



9
10
11
# File 'lib/language_server/file_store.rb', line 9

def from_remote_uri(remote_root:, local_root:, remote_uri:)
  new(remote_root: remote_root, local_root: local_root, local_path: URI(remote_uri).path.sub(remote_root, local_root))
end

Instance Method Details

#==(other) ⇒ Object



30
31
32
# File 'lib/language_server/file_store.rb', line 30

def ==(other)
  eql?(other)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/language_server/file_store.rb', line 26

def eql?(other)
  self.class == other.class && remote_path == other.remote_path
end

#hashObject



34
35
36
# File 'lib/language_server/file_store.rb', line 34

def hash
  self.remote_path.hash
end

#remote_pathObject



22
23
24
# File 'lib/language_server/file_store.rb', line 22

def remote_path
  @remote_path ||= local_path.sub(local_root, remote_root)
end