class Ruboty::Ragoon::Remind

Constants

NOTIFY_BEFORE_EVENT_START

Attributes

brain[R]
event[R]

Public Class Methods

new(brain) click to toggle source
# File lib/ruboty/ragoon/remind.rb, line 9
def initialize(brain)
  @brain = brain
end

Public Instance Methods

retrieve() click to toggle source
# File lib/ruboty/ragoon/remind.rb, line 13
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.between?(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