Class: Addic7ed::Subtitle
- Inherits:
-
Object
- Object
- Addic7ed::Subtitle
- Defined in:
- lib/addic7ed/subtitle.rb
Instance Attribute Summary collapse
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#downloads ⇒ Object
readonly
Returns the value of attribute downloads.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#url ⇒ Object
Returns the value of attribute url.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#via ⇒ Object
readonly
Returns the value of attribute via.
Instance Method Summary collapse
- #can_replace?(other_subtitle) ⇒ Boolean
-
#initialize(options = {}) ⇒ Subtitle
constructor
A new instance of Subtitle.
- #is_completed? ⇒ Boolean
- #is_featured? ⇒ Boolean
- #to_s ⇒ Object
- #works_for?(version = '', no_hi = false) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Subtitle
Returns a new instance of Subtitle.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/addic7ed/subtitle.rb', line 7 def initialize( = {}) @version = Addic7edVersionNormalizer.call([:version]) @language = [:language] @status = [:status] @url = [:url] @via = [:via] @hi = [:hi] @downloads = [:downloads].to_i || 0 @comment = Addic7edCommentNormalizer.call([:comment]) end |
Instance Attribute Details
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
4 5 6 |
# File 'lib/addic7ed/subtitle.rb', line 4 def comment @comment end |
#downloads ⇒ Object (readonly)
Returns the value of attribute downloads.
4 5 6 |
# File 'lib/addic7ed/subtitle.rb', line 4 def downloads @downloads end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
4 5 6 |
# File 'lib/addic7ed/subtitle.rb', line 4 def language @language end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/addic7ed/subtitle.rb', line 4 def status @status end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/addic7ed/subtitle.rb', line 5 def url @url end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
4 5 6 |
# File 'lib/addic7ed/subtitle.rb', line 4 def version @version end |
#via ⇒ Object (readonly)
Returns the value of attribute via.
4 5 6 |
# File 'lib/addic7ed/subtitle.rb', line 4 def via @via end |
Instance Method Details
#can_replace?(other_subtitle) ⇒ Boolean
27 28 29 30 31 32 33 |
# File 'lib/addic7ed/subtitle.rb', line 27 def can_replace?(other_subtitle) return false unless is_completed? return true if other_subtitle.nil? language == other_subtitle.language && is_compatible_with?(other_subtitle.version) && is_more_popular_than?(other_subtitle) end |
#is_completed? ⇒ Boolean
39 40 41 |
# File 'lib/addic7ed/subtitle.rb', line 39 def is_completed? status == 'Completed' end |
#is_featured? ⇒ Boolean
35 36 37 |
# File 'lib/addic7ed/subtitle.rb', line 35 def is_featured? via == "http://addic7ed.com" end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/addic7ed/subtitle.rb', line 18 def to_s "#{url}\t->\t#{version} (#{language}, #{status}) [#{downloads} downloads]#{" (via #{via})" if via}" end |
#works_for?(version = '', no_hi = false) ⇒ Boolean
22 23 24 25 |
# File 'lib/addic7ed/subtitle.rb', line 22 def works_for?(version = '', no_hi = false) hi_works = !@hi || !no_hi is_completed? and is_compatible_with? version and hi_works end |