class STLReader

Attributes

stl_sub_title_lines[R]

Public Class Methods

new() click to toggle source
# File lib/subtitle_converter/stl_reader.rb, line 7
def initialize
  @stl_sub_title_lines = []
end

Public Instance Methods

import_stl_content(file_name) click to toggle source
# File lib/subtitle_converter/stl_reader.rb, line 11
def import_stl_content(file_name)
  content = File.read(file_name)
  parse_stl_content(content)
end
parse_stl_content(content) click to toggle source
# File lib/subtitle_converter/stl_reader.rb, line 16
def parse_stl_content(content)

  @stl_sub_title_lines = content.lines.collect { |line|
    matchdata = line.match(/(\d{2}(?::[0-5]\d){3})\s+,\s+(\d{2}(?::[0-5]\d){3})\s+,\s+(.*)/)
    matchdata.nil? ? nil : matchdata[1] + "#" + matchdata[2] + "#" + matchdata[3]
  }
  @stl_sub_title_lines.compact!
end