Class: RuboCop::Markdown::Position

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/markdown/position.rb

Overview

Get 0-indexed position of the node from line and column based position.

Instance Method Summary collapse

Constructor Details

#initialize(column:, content:, line:) ⇒ Position

Returns a new instance of Position.

Parameters:

  • column (Integer)
  • content (String)
  • line (Integer)


10
11
12
13
14
15
16
17
18
# File 'lib/rubocop/markdown/position.rb', line 10

def initialize(
  column:,
  content:,
  line:
)
  @column = column
  @content = content
  @line = line
end

Instance Method Details

#indexInteger

Returns:

  • (Integer)


21
22
23
# File 'lib/rubocop/markdown/position.rb', line 21

def index
  @content.lines[...@line].join.length + @column - 1
end