Sha256: 0403084ec894a3e9ddabbad2fd76338aeff948112ccdfe97a23189072fe5ed3b

Contents?: true

Size: 859 Bytes

Versions: 2

Compression:

Stored size: 859 Bytes

Contents

require 'saru/support/time_converter'

module Saru
  class List
    module UnlockedDate
      include Saru::Support::TimeConverter

      def unlocked_after date
        selected = items.select do |item|
          !item.unlocked_date.nil? &&
          item.unlocked_date > to_unix(date)
        end

        Saru::List.new selected
      end

      def unlocked_before date
        selected = items.select do |item|
          !item.unlocked_date.nil? &&
          item.unlocked_date < to_unix(date)
        end

        Saru::List.new selected
      end

      def unlocked_between start_date, end_date
        selected = items.select do |item|
          !item.unlocked_date.nil? &&
          item.unlocked_date > to_unix(start_date) &&
          item.unlocked_date < to_unix(end_date)
        end

        Saru::List.new selected
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
saru-0.2.0 lib/saru/list/unlocked_date.rb
saru-0.1.0 lib/saru/list/unlocked_date.rb