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
- #==(other) ⇒ Object
- #contain?(location) ⇒ Boolean
-
#initialize(filename, range) ⇒ Location
constructor
A new instance of Location.
- #inspect ⇒ Object
- #rbs? ⇒ Boolean
- #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
29 30 31 32 33 34 35 36 |
# File 'lib/solargraph/location.rb', line 29 def <=>(other) return nil unless other.is_a?(Location) if filename == other.filename range <=> other.range else filename <=> other.filename end end |
#==(other) ⇒ Object
72 73 74 75 |
# File 'lib/solargraph/location.rb', line 72 def == other return false unless other.is_a?(Location) filename == other.filename and range == other.range end |
#contain?(location) ⇒ Boolean
43 44 45 |
# File 'lib/solargraph/location.rb', line 43 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.name}: filename=#{filename}, range=#{range.inspect}>" end |
#rbs? ⇒ Boolean
38 39 40 |
# File 'lib/solargraph/location.rb', line 38 def rbs? filename.end_with?('.rbs') end |
#to_hash ⇒ Hash
56 57 58 59 60 61 |
# File 'lib/solargraph/location.rb', line 56 def to_hash { filename: filename, range: range.to_hash } end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/solargraph/location.rb', line 51 def to_s inspect end |