Class: ThemeCheck::Position
- Inherits:
-
Object
- Object
- ThemeCheck::Position
- Includes:
- PositionHelper
- Defined in:
- lib/theme_check/position.rb
Instance Method Summary collapse
- #end_column ⇒ Object
-
#end_index ⇒ Object
0-indexed, exclusive.
-
#end_row ⇒ Object
0-indexed, exclusive (both taken together are) therefore you might end up on a newline character or the next line.
-
#initialize(needle_arg, contents_arg, line_number_1_indexed: nil, node_markup: nil, node_markup_offset: 0) ⇒ Position
constructor
A new instance of Position.
-
#start_column ⇒ Object
0-indexed, inclusive.
-
#start_index ⇒ Object
0-indexed, inclusive.
- #start_line_offset ⇒ Object
- #start_offset ⇒ Object
-
#start_row ⇒ Object
0-indexed, inclusive.
- #strict_position ⇒ Object
Methods included from PositionHelper
#bounded, #from_index_to_row_column, #from_row_column_to_index
Constructor Details
#initialize(needle_arg, contents_arg, line_number_1_indexed: nil, node_markup: nil, node_markup_offset: 0) ⇒ Position
Returns a new instance of Position.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/theme_check/position.rb', line 7 def initialize( needle_arg, contents_arg, line_number_1_indexed: nil, node_markup: nil, node_markup_offset: 0 # the index of markup inside the node_markup ) @needle = needle_arg @contents = contents_arg @line_number_1_indexed = line_number_1_indexed @node_markup_offset = node_markup_offset @node_markup = node_markup end |
Instance Method Details
#end_column ⇒ Object
63 64 65 |
# File 'lib/theme_check/position.rb', line 63 def end_column strict_position.end_column end |
#end_index ⇒ Object
0-indexed, exclusive
43 44 45 |
# File 'lib/theme_check/position.rb', line 43 def end_index strict_position.end_index end |
#end_row ⇒ Object
0-indexed, exclusive (both taken together are) therefore you might end up on a newline character or the next line
59 60 61 |
# File 'lib/theme_check/position.rb', line 59 def end_row strict_position.end_row end |
#start_column ⇒ Object
0-indexed, inclusive
53 54 55 |
# File 'lib/theme_check/position.rb', line 53 def start_column strict_position.start_column end |
#start_index ⇒ Object
0-indexed, inclusive
38 39 40 |
# File 'lib/theme_check/position.rb', line 38 def start_index contents.index(needle, start_offset) end |
#start_line_offset ⇒ Object
21 22 23 |
# File 'lib/theme_check/position.rb', line 21 def start_line_offset @start_line_offset ||= from_row_column_to_index(contents, line_number, 0) end |
#start_offset ⇒ Object
25 26 27 |
# File 'lib/theme_check/position.rb', line 25 def start_offset @start_offset ||= compute_start_offset end |
#start_row ⇒ Object
0-indexed, inclusive
48 49 50 |
# File 'lib/theme_check/position.rb', line 48 def start_row strict_position.start_row end |
#strict_position ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/theme_check/position.rb', line 29 def strict_position @strict_position ||= StrictPosition.new( needle, contents, start_index, ) end |