Class: VivlioStarter::CLI::PreProcessCommands::CrossReferenceProcessor::LabelCollectorContext

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

Overview

ラベル収集用コンテキスト

Instance Method Summary collapse

Constructor Details

#initialize(source_file, chapter_number) ⇒ LabelCollectorContext

Returns a new instance of LabelCollectorContext.



153
154
155
156
157
158
159
# File 'lib/vivlio_starter/cli/pre_process/cross_reference_processor.rb', line 153

def initialize(source_file, chapter_number)
  @source_file = source_file
  @chapter_number = chapter_number
  @labels = []
  @errors = []
  @counters = Hash.new(0)
end

Instance Method Details

#collect(content) ⇒ Object



161
162
163
164
165
166
167
# File 'lib/vivlio_starter/cli/pre_process/cross_reference_processor.rb', line 161

def collect(content)
  lines = content.lines
  # コードブロックの除外は Masking(唯一の実装)へ委ねる。
  code_lines = CrossReferenceProcessor.code_line_numbers(content)
  lines.each_with_index { |line, idx| process_line(line, idx, lines, code_lines) }
  { labels: @labels, errors: @errors }
end