Class: Solargraph::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/solargraph/location.rb

Overview

A section of text identified by its filename and range.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, range) ⇒ Location

Returns a new instance of Location.

Parameters:



15
16
17
18
# File 'lib/solargraph/location.rb', line 15

def initialize filename, range
  @filename = filename
  @range = range
end

Instance Attribute Details

#filenameString (readonly)

Returns:

  • (String)


8
9
10
# File 'lib/solargraph/location.rb', line 8

def filename
  @filename
end

#rangeSolargraph::Range (readonly)

Returns:



11
12
13
# File 'lib/solargraph/location.rb', line 11

def range
  @range
end

Instance Method Details

#==(other) ⇒ Object



28
29
30
31
# File 'lib/solargraph/location.rb', line 28

def == other
  return false unless other.is_a?(Location)
  filename == other.filename and range == other.range
end

#inspectObject



33
34
35
# File 'lib/solargraph/location.rb', line 33

def inspect
  "#<#{self.class} #{filename}, #{range.inspect}>"
end

#to_hashHash

Returns:



21
22
23
24
25
26
# File 'lib/solargraph/location.rb', line 21

def to_hash
  {
    filename: filename,
    range: range.to_hash
  }
end