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
- #to_s ⇒ Object
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
57 58 59 60 |
# File 'lib/solargraph/location.rb', line 57 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
33 34 35 |
# File 'lib/solargraph/location.rb', line 33 def inspect "<#{self.class.name}: filename=#{filename}, range=#{range.inspect}>" end |
#to_hash ⇒ Hash
42 43 44 45 46 47 |
# File 'lib/solargraph/location.rb', line 42 def to_hash { filename: filename, range: range.to_hash } end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/solargraph/location.rb', line 37 def to_s inspect end |