Class: Solargraph::Location
- Inherits:
-
Object
- Object
- Solargraph::Location
- 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
Constructor Details
#initialize(filename, range) ⇒ Location
Returns a new instance of Location.
16 17 18 19 |
# File 'lib/solargraph/location.rb', line 16 def initialize filename, range @filename = filename @range = range end |
Instance Attribute Details
#filename ⇒ String (readonly)
9 10 11 |
# File 'lib/solargraph/location.rb', line 9 def filename @filename end |
#range ⇒ Solargraph::Range (readonly)
12 13 14 |
# File 'lib/solargraph/location.rb', line 12 def range @range end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
42 43 44 45 |
# File 'lib/solargraph/location.rb', line 42 def == other return false unless other.is_a?(Location) filename == other.filename and range == other.range end |
#contain?(location) ⇒ Boolean
22 23 24 |
# File 'lib/solargraph/location.rb', line 22 def contain? location range.contain?(location.range.start) && range.contain?(location.range.ending) && filename == location.filename end |
#inspect ⇒ Object
47 48 49 |
# File 'lib/solargraph/location.rb', line 47 def inspect "#<#{self.class} #{filename}, #{range.inspect}>" end |
#to_hash ⇒ Hash
27 28 29 30 31 32 |
# File 'lib/solargraph/location.rb', line 27 def to_hash { filename: filename, range: range.to_hash } end |