Sha256: 78c8added16f33a9cf0b7d7fdb627ead082341109269743da96fe17ee5cfcf2e

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

module SimplePvr
  module Model
    class Recording
      attr_accessor :channel, :show_name, :start_time, :duration, :programme, :conflicting

      def initialize(channel, show_name, start_time, duration, programme=nil)
        @channel = channel
        @show_name = show_name
        @start_time = start_time
        @duration = duration
        @programme = programme
      end

      def expired?
        expired_at(Time.now)
      end
      
      def expired_at(time)
        end_time < time
      end
      
      def conflicting?
        conflicting
      end

      def inspect
        "'#{@show_name}' from '#{@channel.name}' at '#{@start_time}' with duration #{@duration} and programme #{@programme}"
      end

      def ==(other)
        other != nil &&
        other.channel == @channel &&
        other.show_name == @show_name &&
        other.start_time == @start_time &&
        other.duration == @duration &&
        other.programme == @programme
      end
      
      private
      def end_time
        @start_time.advance(seconds: duration)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simple_pvr-1.0.0 lib/simple_pvr/model/recording.rb
simple_pvr-0.0.4 lib/simple_pvr/model/recording.rb
simple_pvr-0.0.3 lib/simple_pvr/model/recording.rb
simple_pvr-0.0.2 lib/simple_pvr/model/recording.rb
simple_pvr-0.0.1 lib/simple_pvr/model/recording.rb