class HamlLint::RubyExtraction::BaseChunk

of the %div in the Ruby file just like there is in the HAML file.
uses a ‘begin` in the generated Ruby to add indentation for the children
code. For example, there is a chunk that represents a `%div` tag, which
There are chunks for most HAML concepts, even if they don’t represent Ruby
is processing and will insert some Ruby code in a file passed to RuboCop.
A Chunk represents a part of the HAML file that HamlLint::Linter::RuboCop
This is the base class for all of the Chunks of HamlLint::RubyExtraction.

def assemble_in(coordinator)

def assemble_in(coordinator)
  coordinator.add_lines(@ruby_lines,
                        haml_line_index: haml_line_index,
                        skip_indexes_in_source_map: skip_line_indexes_in_source_map)
end

def full_assemble(coordinator)

def full_assemble(coordinator)
  if wrap_in_markers
    @start_marker_line_number = coordinator.add_marker(start_marker_indent,
                                                       haml_line_index: haml_line_index)
    assemble_in(coordinator)
    coordinator.add_marker(@end_marker_indent, haml_line_index: haml_end_line_index)
  else
    assemble_in(coordinator)
  end
end

def fuse(_following_chunk)

If no fusion is possible, returns nil
Return a new chunk which is the result of fusing self with the given following chunk.
To be overridden in subclasses.
def fuse(_following_chunk)
  nil
end

def haml_end_line_index

def haml_end_line_index
  # the .max is needed to handle cases with 0 nb_haml_lines
  [@haml_line_index + nb_haml_lines - 1, @haml_line_index].max
end

def initialize(node,

def initialize(node,
               ruby_lines,
               end_marker_indent:, haml_line_index: node.line - 1)
  ruby_lines = [ruby_lines] if ruby_lines.is_a?(String)
  @node = node
  @ruby_lines = ruby_lines
  @haml_line_index = haml_line_index
  @end_marker_indent = end_marker_indent
end

def nb_haml_lines

def nb_haml_lines
  @ruby_lines.size - skip_line_indexes_in_source_map.size
end

def skip_line_indexes_in_source_map

def skip_line_indexes_in_source_map
  []
end

def start_marker_indent

def start_marker_indent
  ruby_lines.first[/ */].size
end

def transfer_correction(coordinator, _all_corrected_ruby_lines, haml_lines)

Can be overridden by subclasses to make it do nothing
already have been corrected and so require nothing.
* When fixing indentation of lines that follow a corrected line, those following lines will
* No need to track when lines in haml_lines are moved to apply changes later in the file
of this approach:
This will be called on ruby chunks in the reverse order they were created. Two benefits

indentation.
all_corrected_ruby_lines. This can change non-ruby parts to, especially for
Overwrites haml_lines to match the Ruby code that was corrected by RuboCop which is in
def transfer_correction(coordinator, _all_corrected_ruby_lines, haml_lines)
  to_ruby_lines = coordinator.extract_from_corrected_lines(@start_marker_line_number, @ruby_lines.size)
  transfer_correction_logic(coordinator, to_ruby_lines, haml_lines)
end

def transfer_correction_logic(_coordinator, _to_ruby_lines, _haml_lines)

extracted using #extract_from by #transfer_correction)
This method only received the ruby code that belongs to this chunk. (It was

Logic to transfer the corrections that turned from_ruby_lines into to_ruby_lines.

To be overridden by subclasses.
def transfer_correction_logic(_coordinator, _to_ruby_lines, _haml_lines)
  raise "Implement #transfer_correction_logic in #{self.class.name}"
end

def wrap_in_markers

def wrap_in_markers
  true
end