Class: MyShows::Show

Inherits:
Hashie::Mash
  • Object
show all
Defined in:
lib/my_shows/show.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*attrs) ⇒ Show

Returns a new instance of Show.



14
15
16
17
# File 'lib/my_shows/show.rb', line 14

def initialize(*attrs)
  super
  attrs.last[:episode].show = self if attrs.last && attrs.last[:episode]
end

Class Method Details

.clientObject



6
7
8
# File 'lib/my_shows/show.rb', line 6

def self.client
  @client ||= SidereelClient.new ENV['SIDEREEL_USERNAME'], ENV['SIDEREEL_PASSWORD']
end

.client=(client) ⇒ Object



10
11
12
# File 'lib/my_shows/show.rb', line 10

def self.client= client
  @client = client
end

.next_episodesObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/my_shows/show.rb', line 19

def self.next_episodes
  client.tracked_tv_shows.first[1].map(&:tv_show).reject do |show_data|
    MyShows.logger.debug "TV Show data: #{show_data.inspect}"
    next_episode = show_data.next_episode
    next_episode.nil? || next_episode.is_upcoming
  end.map do |show_data|
    next_episode_data = show_data.next_episode

    episode = MyShows::Episode.new(season: next_episode_data.season_number,
      episode: next_episode_data.season_ordinal)

    Show.new name: show_data.complete_name, episode: episode
  end
end