Class: SubtitleIt::Subtitle

Inherits:
Object
  • Object
show all
Includes:
Comparable, Formats
Defined in:
lib/subtitle_it/subtitle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Formats

#endl, #parse_ass, #parse_mpl, #parse_rsb, #parse_srt, #parse_sub, #parse_time, #parse_xml, #parse_yml, #ratio, #to_ass, #to_mpl, #to_rsb, #to_srt, #to_sub, #to_xml, #to_yml, #xml_lines

Methods included from PlatformEndLine

#endline, #platform

Constructor Details

#initialize(args = {}) ⇒ Subtitle



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/subtitle_it/subtitle.rb', line 20

def initialize(args = {})
  # Looks like opensubtitle is the only provider around..
  # If a second one comes need big refactor...
  if @info = args[:info]
    # @osdb_info         = info
    @osdb_id           = @info['IDSubtitleFile'].to_s
    @original_filename = @info['SubFileName'].to_s
    @format            = @info['SubFormat'].to_s
    @user              = @info['UserNickName'].to_s
    @language          = @info['LanguageName'].to_s
    @release_name      = @info['MovieReleaseName'].to_s
    @download_count    = @info['SubDownloadsCnt'].to_i
    @rating            = @info['SubRating'].to_f
    @uploaded_at       = @info['SubAddDate'].to_s # TODO: convert to time object?
    @download_url      = @info['SubDownloadLink'].to_s
  end
  @fps = args[:fps] || 23.976
  parse_dump(args[:dump], args[:format]) if args[:dump]
end

Instance Attribute Details

#download_countObject (readonly)

Returns the value of attribute download_count.



17
18
19
# File 'lib/subtitle_it/subtitle.rb', line 17

def download_count
  @download_count
end

#download_urlObject (readonly)

Returns the value of attribute download_url.



17
18
19
# File 'lib/subtitle_it/subtitle.rb', line 17

def download_url
  @download_url
end

#filenameObject (readonly)

Returns the value of attribute filename.



17
18
19
# File 'lib/subtitle_it/subtitle.rb', line 17

def filename
  @filename
end

#formatObject (readonly)

Returns the value of attribute format.



17
18
19
# File 'lib/subtitle_it/subtitle.rb', line 17

def format
  @format
end

#fps=(value) ⇒ Object (writeonly)

Sets the attribute fps



42
43
44
# File 'lib/subtitle_it/subtitle.rb', line 42

def fps=(value)
  @fps = value
end

#idObject (readonly)

Returns the value of attribute id.



17
18
19
# File 'lib/subtitle_it/subtitle.rb', line 17

def id
  @id
end

#infoObject (readonly)

Returns the value of attribute info.



17
18
19
# File 'lib/subtitle_it/subtitle.rb', line 17

def info
  @info
end

#languageObject (readonly)

Returns the value of attribute language.



17
18
19
# File 'lib/subtitle_it/subtitle.rb', line 17

def language
  @language
end

#linesObject

Returns the value of attribute lines.



17
18
19
# File 'lib/subtitle_it/subtitle.rb', line 17

def lines
  @lines
end

#original_filenameObject (readonly)

Returns the value of attribute original_filename.



17
18
19
# File 'lib/subtitle_it/subtitle.rb', line 17

def original_filename
  @original_filename
end

#osdb_idObject (readonly)

Returns the value of attribute osdb_id.



17
18
19
# File 'lib/subtitle_it/subtitle.rb', line 17

def osdb_id
  @osdb_id
end

#ratingObject (readonly)

Returns the value of attribute rating.



17
18
19
# File 'lib/subtitle_it/subtitle.rb', line 17

def rating
  @rating
end

#rawObject (readonly)

Returns the value of attribute raw.



17
18
19
# File 'lib/subtitle_it/subtitle.rb', line 17

def raw
  @raw
end

#release_nameObject (readonly)

Returns the value of attribute release_name.



17
18
19
# File 'lib/subtitle_it/subtitle.rb', line 17

def release_name
  @release_name
end

#styleObject

Returns the value of attribute style.



17
18
19
# File 'lib/subtitle_it/subtitle.rb', line 17

def style
  @style
end

#userObject (readonly)

Returns the value of attribute user.



17
18
19
# File 'lib/subtitle_it/subtitle.rb', line 17

def user
  @user
end

Instance Method Details

#<=>(other) ⇒ Object



48
49
50
# File 'lib/subtitle_it/subtitle.rb', line 48

def <=>(other)
  rating <=> other.rating
end

#data=(data) ⇒ Object



44
45
46
# File 'lib/subtitle_it/subtitle.rb', line 44

def data=(data)
  @raw = data
end