Module: VivlioStarter::CLI::Build::ChapterConfig

Defined in:
lib/vivlio_starter/cli/build/chapter_config.rb

Overview

章 HTML の絞り込みモジュール

Class Method Summary collapse

Class Method Details

.htmls_for_range(base_dir, range, keep_numbers = nil) ⇒ Object

ディレクトリ内の *.html から、章番号レンジと keep_numbers でフィルタ 注: アンダースコア始まりのファイルは \A(\d+)- パターンにマッチしないため自動的に除外される



22
23
24
25
26
27
28
# File 'lib/vivlio_starter/cli/build/chapter_config.rb', line 22

def htmls_for_range(base_dir, range, keep_numbers = nil)
  Dir.glob(File.join(base_dir, '*.html')).select do |path|
    bn = File.basename(path, '.html')
    n = bn[/\A(\d+)-/, 1]&.to_i
    n && range.include?(n) && (keep_numbers.nil? || keep_numbers.include?(n))
  end.sort
end