Sha256: 1aaa4168a78b689bfe826914986958926f33b85abcd391a08855b37c647d7cf0

Contents?: true

Size: 676 Bytes

Versions: 1

Compression:

Stored size: 676 Bytes

Contents

module Ruboty
  module Ragoon
    class Remind
      include NotifyOnce
      attr_reader :brain, :event

      NOTIFY_BEFORE_EVENT_START = 3 # minutes before start_at

      def initialize(brain)
        @brain = brain
      end

      def retrieve
        now = Time.now.localtime

        @event = Event.new
        @event.filter_events do |event|
          Time.parse(event[:start_at]).localtime - NOTIFY_BEFORE_EVENT_START * 60 < now
        end

        new_event_ids = not_notified_ids(@event.events.map { |event| event[:id] })
        @event.filter_events do |event|
          new_event_ids.include?(event[:id])
        end

        @event
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruboty-ragoon-0.5.0 lib/ruboty/ragoon/remind.rb