Sha256: 758c8e0a6d8109db936589b6364a375c3a1f245d30d5475c8f9df13a6a22bd33
Contents?: true
Size: 741 Bytes
Versions: 6
Compression:
Stored size: 741 Bytes
Contents
module JpQuest # SNBT形式のファイルからsubtitle: "some subtitle"を抽出するモジュール module SubtitleExtractor # 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
Version data entries
6 entries across 6 versions & 1 rubygems