Class: Ipodcastly::Client::Episode
- Inherits:
-
Object
- Object
- Ipodcastly::Client::Episode
- Defined in:
- lib/ipodcastly/client/episode.rb
Instance Attribute Summary collapse
-
#reference ⇒ Object
readonly
Returns the value of attribute reference.
Instance Method Summary collapse
- #audio? ⇒ Boolean
- #duration ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize(reference) ⇒ Episode
constructor
A new instance of Episode.
- #listened? ⇒ Boolean
- #mark_as_listened ⇒ Object
- #never_played? ⇒ Boolean
- #position ⇒ Object
- #position=(time) ⇒ Object
- #title ⇒ Object
- #updateable? ⇒ Boolean
Constructor Details
#initialize(reference) ⇒ Episode
Returns a new instance of Episode.
6 7 8 |
# File 'lib/ipodcastly/client/episode.rb', line 6 def initialize(reference) @reference = reference end |
Instance Attribute Details
#reference ⇒ Object (readonly)
Returns the value of attribute reference.
4 5 6 |
# File 'lib/ipodcastly/client/episode.rb', line 4 def reference @reference end |
Instance Method Details
#audio? ⇒ Boolean
35 36 37 |
# File 'lib/ipodcastly/client/episode.rb', line 35 def audio? @reference.video_kind.get == :none end |
#duration ⇒ Object
14 15 16 |
# File 'lib/ipodcastly/client/episode.rb', line 14 def duration @duration ||= @reference.duration.get end |
#enabled? ⇒ Boolean
31 32 33 |
# File 'lib/ipodcastly/client/episode.rb', line 31 def enabled? @reference.enabled.get end |
#listened? ⇒ Boolean
47 48 49 |
# File 'lib/ipodcastly/client/episode.rb', line 47 def listened? enabled? && !never_played? end |
#mark_as_listened ⇒ Object
27 28 29 |
# File 'lib/ipodcastly/client/episode.rb', line 27 def mark_as_listened @reference.played_count.set(1) end |
#never_played? ⇒ Boolean
39 40 41 |
# File 'lib/ipodcastly/client/episode.rb', line 39 def never_played? position.zero? && @reference.played_count.get.zero? end |
#position ⇒ Object
18 19 20 |
# File 'lib/ipodcastly/client/episode.rb', line 18 def position @position ||= @reference.played_count.get > 0 ? duration : @reference.bookmark.get end |
#position=(time) ⇒ Object
22 23 24 25 |
# File 'lib/ipodcastly/client/episode.rb', line 22 def position=(time) @position = time @reference.bookmark.set(time) end |
#title ⇒ Object
10 11 12 |
# File 'lib/ipodcastly/client/episode.rb', line 10 def title @title ||= @reference.name.get end |
#updateable? ⇒ Boolean
43 44 45 |
# File 'lib/ipodcastly/client/episode.rb', line 43 def updateable? enabled? && never_played? end |