Class: Solargraph::Location
- Inherits:
-
Object
- Object
- Solargraph::Location
- Includes:
- Equality
- Defined in:
- lib/solargraph/location.rb
Overview
A pointer to a section of source text identified by its filename and Range.
Instance Attribute Summary collapse
- #filename ⇒ String readonly
- #range ⇒ Solargraph::Range readonly
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #contain?(location) ⇒ Boolean
-
#initialize(filename, range) ⇒ Location
constructor
A new instance of Location.
- #inspect ⇒ Object
- #to_hash ⇒ Hash
Methods included from Equality
Constructor Details
#initialize(filename, range) ⇒ Location
Returns a new instance of Location.
18 19 20 21 |
# File 'lib/solargraph/location.rb', line 18 def initialize filename, range @filename = filename @range = range end |
Instance Attribute Details
#filename ⇒ String (readonly)
11 12 13 |
# File 'lib/solargraph/location.rb', line 11 def filename @filename end |
#range ⇒ Solargraph::Range (readonly)
14 15 16 |
# File 'lib/solargraph/location.rb', line 14 def range @range end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
49 50 51 52 |
# File 'lib/solargraph/location.rb', line 49 def == other return false unless other.is_a?(Location) filename == other.filename and range == other.range end |
#contain?(location) ⇒ Boolean
29 30 31 |
# File 'lib/solargraph/location.rb', line 29 def contain? location range.contain?(location.range.start) && range.contain?(location.range.ending) && filename == location.filename end |
#inspect ⇒ Object
54 55 56 |
# File 'lib/solargraph/location.rb', line 54 def inspect "#<#{self.class} #{filename}, #{range.inspect}>" end |
#to_hash ⇒ Hash
34 35 36 37 38 39 |
# File 'lib/solargraph/location.rb', line 34 def to_hash { filename: filename, range: range.to_hash } end |