Class: VivlioStarter::CLI::PreProcessCommands::CrossReferenceProcessor::CaptionedBlockTransformer

Inherits:
Object
  • Object
show all
Defined in:
lib/vivlio_starter/cli/pre_process/cross_reference_processor.rb

Overview

キャプション付きブロック変換クラス rubocop:disable Metrics/ClassLength

Instance Method Summary collapse

Constructor Details

#initialize(content, filename, labels_map) ⇒ CaptionedBlockTransformer

Returns a new instance of CaptionedBlockTransformer.



301
302
303
304
305
306
# File 'lib/vivlio_starter/cli/pre_process/cross_reference_processor.rb', line 301

def initialize(content, filename, labels_map)
  @lines = content.lines
  @filename = filename
  @labels_map = labels_map
  @counters = Hash.new(0)
end

Instance Method Details

#transformObject



308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/vivlio_starter/cli/pre_process/cross_reference_processor.rb', line 308

def transform
  output = []
  idx = 0
  # コードブロックの除外は Masking(唯一の実装)へ委ねる。
  code_lines = CrossReferenceProcessor.code_line_numbers(@lines.join)
  while idx < @lines.size
    idx = if code_lines.include?(idx + 1)
            passthrough(output, idx)
          else
            process_line(output, idx)
          end
  end
  output.join
end