Class: Ipodcastly::Client::Episode

Inherits:
Object
  • Object
show all
Defined in:
lib/ipodcastly/client/episode.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#referenceObject (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

Returns:

  • (Boolean)


35
36
37
# File 'lib/ipodcastly/client/episode.rb', line 35

def audio?
  @reference.video_kind.get == :none
end

#durationObject



14
15
16
# File 'lib/ipodcastly/client/episode.rb', line 14

def duration
  @duration ||= @reference.duration.get
end

#enabled?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/ipodcastly/client/episode.rb', line 31

def enabled?
  @reference.enabled.get
end

#listened?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/ipodcastly/client/episode.rb', line 47

def listened?
   enabled? && !never_played?
end

#mark_as_listenedObject



27
28
29
# File 'lib/ipodcastly/client/episode.rb', line 27

def mark_as_listened
  @reference.played_count.set(1)
end

#never_played?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/ipodcastly/client/episode.rb', line 39

def never_played?
  position.zero? && @reference.played_count.get.zero?
end

#positionObject



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

#titleObject



10
11
12
# File 'lib/ipodcastly/client/episode.rb', line 10

def title
  @title ||= @reference.name.get
end

#updateable?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/ipodcastly/client/episode.rb', line 43

def updateable?
  enabled? && never_played?
end