class HamlLint::RubyExtraction::RubyFilterChunk
Chunk for dealing with ‘:ruby` filter.
Attributes
start_marker_indent[R]
Public Class Methods
new(*args, start_marker_indent:, **kwargs)
click to toggle source
Calls superclass method
HamlLint::RubyExtraction::BaseChunk::new
# File lib/haml_lint/ruby_extraction/ruby_filter_chunk.rb, line 8 def initialize(*args, start_marker_indent:, **kwargs) super(*args, **kwargs) @start_marker_indent = start_marker_indent end
Public Instance Methods
transfer_correction_logic(coordinator, to_ruby_lines, haml_lines)
click to toggle source
# File lib/haml_lint/ruby_extraction/ruby_filter_chunk.rb, line 13 def transfer_correction_logic(coordinator, to_ruby_lines, haml_lines) marker_index = coordinator.find_line_index_of_marker_in_corrections(@start_marker_line_number) new_name_indent = coordinator.corrected_ruby_lines[marker_index].index(/\S/) delta_indent = new_name_indent - @start_marker_indent haml_lines[@haml_line_index - 1] = HamlLint::Utils.indent(haml_lines[@haml_line_index - 1], delta_indent) to_haml_lines = to_ruby_lines.map do |line| if !/\S/.match?(line) # whitespace or empty '' else " #{line}" end end haml_lines[@haml_line_index..haml_end_line_index] = to_haml_lines end