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

Returns a new instance of Subtitle.



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

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
  return unless dump = args[:dump]
  parse_dump(args[:dump], args[:format])
end

Instance Attribute Details

#download_countObject (readonly)

Returns the value of attribute download_count.



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

def download_count
  @download_count
end

#download_urlObject (readonly)

Returns the value of attribute download_url.



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

def download_url
  @download_url
end

#filenameObject (readonly)

Returns the value of attribute filename.



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

def filename
  @filename
end

#formatObject (readonly)

Returns the value of attribute format.



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

def format
  @format
end

#fps=(value) ⇒ Object (writeonly)

Sets the attribute fps

Parameters:

  • value

    the value to set the attribute fps to.



20
21
22
# File 'lib/subtitle_it/subtitle.rb', line 20

def fps=(value)
  @fps = value
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#infoObject (readonly)

Returns the value of attribute info.



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

def info
  @info
end

#languageObject (readonly)

Returns the value of attribute language.



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

def language
  @language
end

#linesObject

Returns the value of attribute lines.



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

def lines
  @lines
end

#original_filenameObject (readonly)

Returns the value of attribute original_filename.



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

def original_filename
  @original_filename
end

#osdb_idObject (readonly)

Returns the value of attribute osdb_id.



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

def osdb_id
  @osdb_id
end

#ratingObject (readonly)

Returns the value of attribute rating.



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

def rating
  @rating
end

#rawObject (readonly)

Returns the value of attribute raw.



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

def raw
  @raw
end

#release_nameObject (readonly)

Returns the value of attribute release_name.



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

def release_name
  @release_name
end

#styleObject

Returns the value of attribute style.



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

def style
  @style
end

#userObject (readonly)

Returns the value of attribute user.



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

def user
  @user
end

Instance Method Details

#<=>(other) ⇒ Object



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

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

#data=(data) ⇒ Object



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

def data=(data)
  @raw = data
end