Sha256: babcbd67d5f71bc4d3b18a6dbefcf5d0c44cfe6f50c16edb77bcc61d44662b10

Contents?: true

Size: 702 Bytes

Versions: 6

Compression:

Stored size: 702 Bytes

Contents

module JpQuest
  # SNBT形式のファイルからtitle: "some title"を抽出するモジュール
  module TitleExtractor
    # title: "some title"を抽出する
    #
    # @param [String] file_path ファイルのパス
    # @return [Array<Hash>] タイトルと行番号の配列
    def extract_titles(file_path)
      titles = []
      lines = File.readlines(file_path)
      lines.each_with_index do |line, index|
        next unless start_of?(line, key: :title)

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

      titles
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jp_quest-0.2.1 lib/jp_quest/extractor/title.rb
jp_quest-0.2.0 lib/jp_quest/extractor/title.rb
jp_quest-0.1.3 lib/jp_quest/extractor/title.rb
jp_quest-0.1.2 lib/jp_quest/extractor/title.rb
jp_quest-0.1.1 lib/jp_quest/extractor/title.rb
jp_quest-0.1.0 lib/jp_quest/extractor/title.rb