Class: CoffeeOutside::RssDispatcher

Inherits:
DispatcherBase show all
Defined in:
lib/coffeeoutside/dispatchers/rss.rb

Instance Attribute Summary

Attributes inherited from DispatcherBase

#end_time, #forecast, #location, #start_time

Instance Method Summary collapse

Methods inherited from DispatcherBase

#debug_method, #initialize, #notify, #production?

Constructor Details

This class inherits a constructor from CoffeeOutside::DispatcherBase

Instance Method Details

#generate_descriptionObject



8
9
10
11
12
13
# File 'lib/coffeeoutside/dispatchers/rss.rb', line 8

def generate_description
  items = []
  items.append(["Address: #{@location.address}"]) if @location.address
  items.append(@forecast)
  items.join("\n")
end

#generate_rss_stringObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/coffeeoutside/dispatchers/rss.rb', line 15

def generate_rss_string
  RSS::Maker.make("2.0") do |maker|
    maker.channel.language = "en"
    maker.channel.author = "CoffeeOutsideBot"
    maker.channel.updated = Time.now.to_s
    maker.channel.about = "https://coffeeoutside.bike/yyc.rss"
    maker.channel.link = "https://coffeeoutside.bike/yyc.rss"
    maker.channel.description = "CoffeeOutside is a weekly meetup where Calgarians bike/walk/run/rollerblade to a location, drink coffee/tea/some hot or cold beverage, and shoot the breeze" # rubocop:disable Layout/LineLength
    maker.channel.title = "CoffeeOutside"

    maker.items.new_item do |item|
      item.link = @location.url if @location.url
      item.title = "Location for #{@start_time.strftime("%Y-%m-%d")}: #{@location.name}"
      item.description = generate_description
      item.updated = Time.now.to_s
    end
  end
end

#notify_debugObject



39
40
41
# File 'lib/coffeeoutside/dispatchers/rss.rb', line 39

def notify_debug
  puts generate_rss_string
end

#notify_productionObject



34
35
36
37
# File 'lib/coffeeoutside/dispatchers/rss.rb', line 34

def notify_production
  i = File.open("yyc.rss", "w")
  i.write(generate_rss_string)
end