Sha256: 88ae610e6213061f4faeb8e1fe6ed06c0cea8d78832cbcd4252f148b1f8625c5

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

module MrVideo

  class Episode

    attr_reader :cassette

    def initialize(cassette, http_interaction)
      @cassette = cassette
      @http_interaction = http_interaction
    end

    def id
      url.hash
    end

    def request_method
      request['method']
    end

    def url
      request['uri']
    end

    def website_url
      @website_url ||= "#{uri.scheme}://#{uri.host}"
    end

    def content
      response['body']['string']
    end

    def content_type
      response['headers']['Content-Type'][0]
    end

    def recorded_at
      Time.zone.parse(http_interaction['recorded_at'].to_s).to_datetime
    end

    def destroy
      cassette.send(:destroy_episode, self)
    end

    def inspect
      to_s
    end

    def to_param
      id.to_s
    end

    private

    def request
      http_interaction['request']
    end

    def response
      http_interaction['response']
    end

    def uri
      @uri ||= URI(url)
    end

    def http_interaction
      @http_interaction
    end

  end # Episode class

end # MrVideo module

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mr_video-1.0.5 app/models/mr_video/episode.rb
mr_video-1.0.4 app/models/mr_video/episode.rb
mr_video-1.0.2 app/models/mr_video/episode.rb
mr_video-1.0.1 app/models/mr_video/episode.rb
mr_video-1.0.0 app/models/mr_video/episode.rb