module Watchbuffy

Constants

ANGEL_SEASONS
BUFFY_SEASONS
EPISODES
VERSION

Public Class Methods

pick(show: %w[buffy angel], buffy_season: BUFFY_SEASONS, angel_season: ANGEL_SEASONS, exclude_characters: []) click to toggle source
# File lib/watchbuffy.rb, line 11
def pick(show: %w[buffy angel], buffy_season: BUFFY_SEASONS, angel_season: ANGEL_SEASONS, exclude_characters: [])
  episode = EPISODES.select{ |e|
    show.include?(e["show"]) &&
    (
      e["show"] == "buffy" && Array(buffy_season).include?(e["season"]) ||
      e["show"] == "angel" && Array(angel_season).include?(e["season"])
    ) &&
    (Array(e["includesCharacters"]) & Array(exclude_characters)).length.zero?
  }.sample

  if episode
    watch(episode)
  else
    puts "No episode found"
  end
end

Private Class Methods

watch(episode) click to toggle source
# File lib/watchbuffy.rb, line 30
def watch(episode)
  puts \
    '▶️  Watch %s episode %s×%s: "%s"' % [
      episode["show"].capitalize,
      episode["season"],
      episode["numberInSeason"],
      episode["title"],
    ]
end