Class: SubtitleIt::Subtitle

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#filenameObject (readonly)

Returns the value of attribute filename.



12
13
14
# File 'lib/subtitle_it/subtitle.rb', line 12

def filename
  @filename
end

#formatObject (readonly)

Returns the value of attribute format.



12
13
14
# File 'lib/subtitle_it/subtitle.rb', line 12

def format
  @format
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/subtitle_it/subtitle.rb', line 12

def id
  @id
end

#infoObject (readonly)

Returns the value of attribute info.



12
13
14
# File 'lib/subtitle_it/subtitle.rb', line 12

def info
  @info
end

#linesObject

Returns the value of attribute lines.



12
13
14
# File 'lib/subtitle_it/subtitle.rb', line 12

def lines
  @lines
end

#rawObject (readonly)

Returns the value of attribute raw.



12
13
14
# File 'lib/subtitle_it/subtitle.rb', line 12

def raw
  @raw
end

#styleObject

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