Class: Yoda::Parsing::Range
- Inherits:
-
Object
- Object
- Yoda::Parsing::Range
- Defined in:
- lib/yoda/parsing/range.rb
Instance Attribute Summary collapse
-
#begin_location ⇒ Object
readonly
Returns the value of attribute begin_location.
-
#end_location ⇒ Object
readonly
Returns the value of attribute end_location.
Class Method Summary collapse
Instance Method Summary collapse
- #include?(location) ⇒ true, false
-
#initialize(begin_location, end_location) ⇒ Range
constructor
A new instance of Range.
- #move(row:, column:) ⇒ Range
- #to_language_server_protocol_range ⇒ {Symbol => { Symbol => Integer } }
Constructor Details
#initialize(begin_location, end_location) ⇒ Range
Returns a new instance of Range.
7 8 9 10 |
# File 'lib/yoda/parsing/range.rb', line 7 def initialize(begin_location, end_location) @begin_location = begin_location @end_location = end_location end |
Instance Attribute Details
#begin_location ⇒ Object (readonly)
Returns the value of attribute begin_location.
4 5 6 |
# File 'lib/yoda/parsing/range.rb', line 4 def begin_location @begin_location end |
#end_location ⇒ Object (readonly)
Returns the value of attribute end_location.
4 5 6 |
# File 'lib/yoda/parsing/range.rb', line 4 def end_location @end_location end |
Class Method Details
.of_ast_location(ast_location) ⇒ Location?
14 15 16 17 18 19 20 |
# File 'lib/yoda/parsing/range.rb', line 14 def self.of_ast_location(ast_location) return nil unless Location.valid_location?(ast_location) new( Location.new(row: ast_location.line, column: ast_location.column), Location.new(row: ast_location.last_line, column: ast_location.last_column), ) end |
Instance Method Details
#include?(location) ⇒ true, false
36 37 38 |
# File 'lib/yoda/parsing/range.rb', line 36 def include?(location) begin_location <= location && location <= end_location end |
#move(row:, column:) ⇒ Range
30 31 32 |
# File 'lib/yoda/parsing/range.rb', line 30 def move(row:, column:) self.class.new(begin_location.move(row: row, column: column), end_location.move(row: row, column: column)) end |
#to_language_server_protocol_range ⇒ {Symbol => { Symbol => Integer } }
23 24 25 |
# File 'lib/yoda/parsing/range.rb', line 23 def to_language_server_protocol_range { start: begin_location.to_language_server_protocol_range, end: end_location.to_language_server_protocol_range } end |