Class: Eventify

Inherits:
Object
  • Object
show all
Defined in:
lib/eventify.rb,
lib/eventify/version.rb,
lib/eventify/provider/base.rb

Defined Under Namespace

Modules: Provider Classes: Configuration, Database, Mail

Constant Summary collapse

VERSION =
"4.0.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration = Eventify::Configuration.new) ⇒ Eventify

Returns a new instance of Eventify.



13
14
15
# File 'lib/eventify.rb', line 13

def initialize(configuration=Eventify::Configuration.new)
  @configuration = configuration
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



11
12
13
# File 'lib/eventify.rb', line 11

def configuration
  @configuration
end

#providersObject



35
36
37
38
39
40
41
# File 'lib/eventify.rb', line 35

def providers
  @providers ||= [
    Eventify::Provider::Piletilevi,
    Eventify::Provider::Livenation,
    Eventify::Provider::ApolloKino
  ]
end

Instance Method Details

#all_eventsObject



17
18
19
# File 'lib/eventify.rb', line 17

def all_events
  @all_events ||= providers.flat_map(&:fetch).uniq
end

#new_eventsObject



21
22
23
# File 'lib/eventify.rb', line 21

def new_events
  @new_events ||= all_events.reject(&:exists?)
end

#process_new_eventsObject



25
26
27
28
29
30
31
# File 'lib/eventify.rb', line 25

def process_new_events
  all_new_events = new_events
  return if all_new_events.empty?

  Eventify::Mail.deliver all_new_events, @configuration
  all_new_events.each(&:save)
end