subtitle_parser 0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/subtitle_parser.rb +26 -0
  2. metadata +47 -0
@@ -0,0 +1,26 @@
1
+ class SubtitleParser
2
+
3
+ def parse content
4
+ subs = []
5
+ unless content.empty?
6
+ content.scan(/^(?<order>(\d{1,4}))\n(?<begins>.+)\s*-->\s*(?<ends>.+)\n(?<sentences>(.+\n)*)/) do |order, begins, ends, sentence|
7
+ subs << Subtitle.new(order, begins, ends, sentence.gsub("\n", ""))
8
+ end
9
+ end
10
+
11
+ return subs
12
+ end
13
+
14
+ class Subtitle
15
+ attr_reader :order, :begins, :ends, :sentence
16
+
17
+ def initialize order, begins, ends, sentence
18
+ @order = order.to_i
19
+ @begins = begins
20
+ @ends = ends
21
+ @sentence = sentence
22
+ end
23
+
24
+ end
25
+
26
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: subtitle_parser
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.9'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tiago F. Silva
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-29 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Parse your .srt files into Subtitle objects. This objects represent one
15
+ subtitle from the original file, with the order it appears on the movie, sentences
16
+ (the subtitle itself), time of the movie when it starts and time when it ends.
17
+ email: aeroboom@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - lib/subtitle_parser.rb
23
+ homepage: http://rubygems.org/gems/subtitle_parser
24
+ licenses: []
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 1.8.23
44
+ signing_key:
45
+ specification_version: 3
46
+ summary: Parse your .srt files
47
+ test_files: []