Class: OSDb::Sub
- Inherits:
-
Object
- Object
- OSDb::Sub
- Defined in:
- lib/osdb/sub.rb
Instance Attribute Summary collapse
-
#bad_reports_count ⇒ Object
readonly
Returns the value of attribute bad_reports_count.
-
#downloads_count ⇒ Object
readonly
Returns the value of attribute downloads_count.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#movie_name ⇒ Object
readonly
Returns the value of attribute movie_name.
-
#rating ⇒ Object
readonly
Returns the value of attribute rating.
-
#raw_data ⇒ Object
readonly
Returns the value of attribute raw_data.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#user_ranks ⇒ Object
readonly
Returns the value of attribute user_ranks.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(data) ⇒ Sub
constructor
A new instance of Sub.
-
#score ⇒ Object
Totaly subjective formula to evaluate subtitle quality Originaly developed by runa (github.com/runa) github.com/byroot/ruby-osdb/commit/9d71775#L0R122.
- #uploader_score ⇒ Object
Constructor Details
#initialize(data) ⇒ Sub
Returns a new instance of Sub.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/osdb/sub.rb', line 10 def initialize(data) @url = URI.parse(data['SubDownloadLink']) @format = data['SubFormat'] @language = Language.from_iso639_2b(data['SubLanguageID']) = data['SubRating'].to_f @user_ranks = data['UserRank'] @movie_name = data['MovieName'] @filename = data['SubFileName'] @downloads_count = data['SubDownloadsCnt'].to_i @bad_reports_count = data['SubBad'].to_i @raw_data = data end |
Instance Attribute Details
#bad_reports_count ⇒ Object (readonly)
Returns the value of attribute bad_reports_count.
7 8 9 |
# File 'lib/osdb/sub.rb', line 7 def bad_reports_count @bad_reports_count end |
#downloads_count ⇒ Object (readonly)
Returns the value of attribute downloads_count.
7 8 9 |
# File 'lib/osdb/sub.rb', line 7 def downloads_count @downloads_count end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
7 8 9 |
# File 'lib/osdb/sub.rb', line 7 def filename @filename end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
7 8 9 |
# File 'lib/osdb/sub.rb', line 7 def format @format end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
7 8 9 |
# File 'lib/osdb/sub.rb', line 7 def language @language end |
#movie_name ⇒ Object (readonly)
Returns the value of attribute movie_name.
7 8 9 |
# File 'lib/osdb/sub.rb', line 7 def movie_name @movie_name end |
#rating ⇒ Object (readonly)
Returns the value of attribute rating.
7 8 9 |
# File 'lib/osdb/sub.rb', line 7 def end |
#raw_data ⇒ Object (readonly)
Returns the value of attribute raw_data.
7 8 9 |
# File 'lib/osdb/sub.rb', line 7 def raw_data @raw_data end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/osdb/sub.rb', line 7 def url @url end |
#user_ranks ⇒ Object (readonly)
Returns the value of attribute user_ranks.
7 8 9 |
# File 'lib/osdb/sub.rb', line 7 def user_ranks @user_ranks end |
Instance Method Details
#<=>(other) ⇒ Object
23 24 25 |
# File 'lib/osdb/sub.rb', line 23 def <=>(other) <=> other. end |
#score ⇒ Object
Totaly subjective formula to evaluate subtitle quality Originaly developed by runa (github.com/runa) github.com/byroot/ruby-osdb/commit/9d71775#L0R122
30 31 32 |
# File 'lib/osdb/sub.rb', line 30 def score uploader_score * downloads_count.next * ( + 1) - bad_reports_count / downloads_count.next end |
#uploader_score ⇒ Object
34 35 36 |
# File 'lib/osdb/sub.rb', line 34 def uploader_score user_ranks.empty? ? 1 : 2 end |