Method: NovelConverter#convert_main_for_novel

Defined in:
lib/novelconverter.rb

#convert_main_for_novel(subtitles = nil, is_hotentry = false) ⇒ Object

管理小説変換時の実質的なメイン処理

引数 subtitles にデータを渡した場合はそれを直接使うis_hotentry を有効にすると出力されるテキストファイルにあらすじや作品タイトル等が含まれなくなるまた、 is_hotentry を有効にすると分割も行われなくなる



632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
# File 'lib/novelconverter.rb', line 632

def convert_main_for_novel(subtitles = nil, is_hotentry = false)
  toc = Downloader.get_toc_data(@setting.archive_path)
  unless subtitles
    subtitles = cut_subtitles(toc["subtitles"])
  end
  if is_hotentry == false && @setting.slice_size > 0 && subtitles.length > @setting.slice_size
    stream_io.puts "#{@setting.slice_size}話ごとに分割して変換します"
    array_of_subtitles = subtitles.each_slice(@setting.slice_size).to_a
  else
    array_of_subtitles = [subtitles]
  end
  toc["story"] = @converter.convert(toc["story"], "story")
  site_setting = SiteSetting.find(toc["toc_url"])
  html = HTML.new
  html.strip_decoration_tag = @setting.enable_strip_decoration_tag
  html.set_illust_setting(
    current_url: site_setting["illust_current_url"],
    grep_pattern: site_setting["illust_grep_pattern"]
  )
  array_of_converted_text = []
  array_of_subtitles.each_with_index do |sliced_subtitles, index|
    @converter.subtitles = sliced_subtitles
    html.clear
    sections = subtitles_to_sections(sliced_subtitles, html)
    array_of_converted_text.push(
      create_novel_text_by_template(
        sections, toc, is_hotentry,
        array_of_subtitles.length == 1 ? nil : index + 1
      )
    )
  end

  if is_hotentry
    array_of_converted_text[0]
  else
    array_of_converted_text
  end
end