Sha256: 54e068bac00fab169add36e2af39650f64f849f0ed6ba6956d076b2141f200a1

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 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 similar_to(other)
        other != nil &&
        other.channel == @channel &&
        other.show_name == @show_name &&
        other.start_time == @start_time
      end
      
      def update_with(other)
        @duration = other.duration
        @programme = other.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

1 entries across 1 versions & 1 rubygems

Version Path
simple_pvr-1.1.0 lib/simple_pvr/model/recording.rb