Sha256: cfabf00ead6c01dd37160dce90a489f36b9cb6ebd7e1f88b08c3aa41850fb710

Contents?: true

Size: 794 Bytes

Versions: 1

Compression:

Stored size: 794 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|
          begin
            event_start = Time.parse(event[:start_at]).localtime
            event_start.betwwen?(now, now + NOTIFY_BEFORE_EVENT_START * 60)
          rescue
            false
          end
        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.1 lib/ruboty/ragoon/remind.rb