Class: SubtitleIt::Subtitle
- Inherits:
-
Object
- Object
- SubtitleIt::Subtitle
- Defined in:
- lib/subtitle_it/subtitle.rb
Constant Summary collapse
- EXTS =
%w(srt sub smi txt ssa ass mpl xml yml rsb)
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#style ⇒ Object
Returns the value of attribute style.
Instance Method Summary collapse
- #data=(data) ⇒ Object
- #fps=(fps) ⇒ Object
-
#initialize(dump = nil, format = nil, info = nil) ⇒ Subtitle
constructor
A new instance of Subtitle.
- #parse_dump(dump, format) ⇒ Object
Constructor Details
#initialize(dump = nil, format = nil, info = nil) ⇒ Subtitle
Returns a new instance of Subtitle.
16 17 18 19 20 21 22 23 |
# File 'lib/subtitle_it/subtitle.rb', line 16 def initialize(dump=nil,format=nil,info=nil) @info = info @id = info['IDSubtitleFile'].to_i if info @filename = info['SubFileName'].to_s if info @format = info['SubFormat'].to_s if info @fps=23.976 parse_dump(dump,format) if dump end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
12 13 14 |
# File 'lib/subtitle_it/subtitle.rb', line 12 def filename @filename end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
12 13 14 |
# File 'lib/subtitle_it/subtitle.rb', line 12 def format @format end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/subtitle_it/subtitle.rb', line 12 def id @id end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
12 13 14 |
# File 'lib/subtitle_it/subtitle.rb', line 12 def info @info end |
#lines ⇒ Object
Returns the value of attribute lines.
12 13 14 |
# File 'lib/subtitle_it/subtitle.rb', line 12 def lines @lines end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
12 13 14 |
# File 'lib/subtitle_it/subtitle.rb', line 12 def raw @raw end |
#style ⇒ Object
Returns the value of attribute style.
12 13 14 |
# File 'lib/subtitle_it/subtitle.rb', line 12 def style @style end |
Instance Method Details
#data=(data) ⇒ Object
40 41 42 |
# File 'lib/subtitle_it/subtitle.rb', line 40 def data=(data) @raw = data end |
#fps=(fps) ⇒ Object
36 37 38 |
# File 'lib/subtitle_it/subtitle.rb', line 36 def fps=(fps) @fps = fps end |
#parse_dump(dump, format) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/subtitle_it/subtitle.rb', line 25 def parse_dump(dump,format) raise unless format =~ /^srt$|sub|yml|txt|rsb|xml|ass|mpl/ @raw = dump.kind_of?(String) ? dump : dump.read @format = format parse! end |