Sha256: 74ad84d6d2cdf2d7b1c43b14b526553d138022a7f346a61a2ecc85a2d81d53a6

Contents?: true

Size: 884 Bytes

Versions: 4

Compression:

Stored size: 884 Bytes

Contents

require_relative "../util/indent_helper"

module ModpackLocalizer
  module SNBT
    # SNBT形式のファイルからsubtitle: "some subtitle"を抽出するモジュール
    module SubtitleExtractor
      include IndentHelper

      # subtitle: "some subtitle"を抽出する
      #
      # @param [String] file_path ファイルのパス
      # @return [Array<Hash>] サブタイトルと行番号の配列
      def extract_subtitles(file_path)
        subtitles = []
        lines = File.readlines(file_path)
        lines.each_with_index do |line, index|
          next unless start_of?(line, key: :subtitle)

          subtitles << {
            type: :subtitle,
            text: extract_oneline(line),
            start_line: index,
            end_line: index,
            indent: count_indent(line)
          }
        end

        subtitles
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
modpack_localizer-0.1.3 lib/modpack_localizer/snbt/subtitle_extractor.rb
modpack_localizer-0.1.2 lib/modpack_localizer/snbt/subtitle_extractor.rb
modpack_localizer-0.1.1 lib/modpack_localizer/snbt/subtitle_extractor.rb
modpack_localizer-0.1.0 lib/modpack_localizer/snbt/subtitle_extractor.rb