Sha256: 7cc511870e7ba7d62d0282fe01d07924012bcccfec8c212679ef701d07940418

Contents?: true

Size: 877 Bytes

Versions: 4

Compression:

Stored size: 877 Bytes

Contents

# encoding: utf-8
module Junkie

  require 'sindex'
  require 'securerandom'

  class Episode
    attr_reader :uuid, :id, :series, :found_at
    attr_accessor :description, :status, :pid, :links

    def initialize(series, links, description=nil)
      @uuid = SecureRandom.uuid
      @series = series
      @links = links
      @found_at = DateTime.now
      @description = description
      @status = :found
      @id = episode_identifier
    end

    def to_s
      "%s (%s)" % [ @series, episode_identifier ]
    end

    def to_hash
      {
          uuid: @uuid,
          id: @id,
          series: @series,
          links: @links,
          status: @status,
          found_at: @found_at,
          description: @description
      }
    end

    private

    def episode_identifier
      Sindex::SeriesIndex.extract_episode_identifier(@description)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
junkie-0.1.3 lib/junkie/episode.rb
junkie-0.1.2 lib/junkie/episode.rb
junkie-0.1.1 lib/junkie/episode.rb
junkie-0.1.0 lib/junkie/episode.rb