Class: Spoom::Deadcode::Location
- Inherits:
-
Object
- Object
- Spoom::Deadcode::Location
- Extended by:
- T::Sig
- Includes:
- Comparable
- Defined in:
- lib/spoom/deadcode/location.rb
Defined Under Namespace
Classes: LocationError
Instance Attribute Summary collapse
-
#end_column ⇒ Object
readonly
Returns the value of attribute end_column.
-
#end_line ⇒ Object
readonly
Returns the value of attribute end_line.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#start_column ⇒ Object
readonly
Returns the value of attribute start_column.
-
#start_line ⇒ Object
readonly
Returns the value of attribute start_line.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(file, start_line, start_column, end_line, end_column) ⇒ Location
constructor
A new instance of Location.
- #to_s ⇒ Object
Constructor Details
#initialize(file, start_line, start_column, end_line, end_column) ⇒ Location
Returns a new instance of Location.
37 38 39 40 41 42 43 |
# File 'lib/spoom/deadcode/location.rb', line 37 def initialize(file, start_line, start_column, end_line, end_column) @file = file @start_line = start_line @start_column = start_column @end_line = end_line @end_column = end_column end |
Instance Attribute Details
#end_column ⇒ Object (readonly)
Returns the value of attribute end_column.
26 27 28 |
# File 'lib/spoom/deadcode/location.rb', line 26 def end_column @end_column end |
#end_line ⇒ Object (readonly)
Returns the value of attribute end_line.
26 27 28 |
# File 'lib/spoom/deadcode/location.rb', line 26 def end_line @end_line end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
23 24 25 |
# File 'lib/spoom/deadcode/location.rb', line 23 def file @file end |
#start_column ⇒ Object (readonly)
Returns the value of attribute start_column.
26 27 28 |
# File 'lib/spoom/deadcode/location.rb', line 26 def start_column @start_column end |
#start_line ⇒ Object (readonly)
Returns the value of attribute start_line.
26 27 28 |
# File 'lib/spoom/deadcode/location.rb', line 26 def start_line @start_line end |
Class Method Details
.from_syntax_tree(file, location) ⇒ Object
17 18 19 |
# File 'lib/spoom/deadcode/location.rb', line 17 def from_syntax_tree(file, location) new(file, location.start_line, location.start_column, location.end_line, location.end_column) end |
Instance Method Details
#<=>(other) ⇒ Object
46 47 48 49 50 |
# File 'lib/spoom/deadcode/location.rb', line 46 def <=>(other) return nil unless Location === other to_s <=> other.to_s end |
#to_s ⇒ Object
53 54 55 |
# File 'lib/spoom/deadcode/location.rb', line 53 def to_s "#{@file}:#{@start_line}:#{@start_column}-#{@end_line}:#{@end_column}" end |