aboutsummaryrefslogtreecommitdiffstats
path: root/ramaskrik-program.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ramaskrik-program.rb')
-rw-r--r--ramaskrik-program.rb25
1 files changed, 24 insertions, 1 deletions
diff --git a/ramaskrik-program.rb b/ramaskrik-program.rb
index 0ca62e2..9097522 100644
--- a/ramaskrik-program.rb
+++ b/ramaskrik-program.rb
@@ -1,6 +1,7 @@
require 'date'
require 'nokogiri'
require 'open-uri'
+require 'SVG/Graph/Schedule'
class Movie
attr_reader :title, :start_time, :end_time, :venue
@@ -16,8 +17,30 @@ class Movie
def to_s
"#{title} #{start_time} - #{end_time}, #{venue}"
end
+
+ def triplet
+ [@title, @start_time.strftime("%d.%m.%Y %H:%M"), @end_time.strftime("%d.%m.%Y %H:%M")]
+ end
end
doc = Nokogiri::HTML(open("program.html")) ## open("https://ramaskrik.no/program/"))
movies = doc.css(".kultur-type-movie").map { |movie| Movie.new(movie) }
-puts movies
+days = movies.group_by { |movie| movie.start_time.strftime("%A %d.%m.%Y") }
+days.each do |d, movies|
+ graph = SVG::Graph::Schedule.new({
+ graph_title: d,
+ show_graph_title: true,
+ show_x_guidelines: true,
+ width: 1024,
+ key: false,
+ x_label_format: "%H:%M"
+ })
+
+ venues = movies.group_by { |m| m.venue }
+ venues.each do |v, m|
+ data = m.flat_map { |m| m.triplet }
+ graph.add_data({ title: v, data: data })
+ end
+
+ IO.write("#{d}-program.svg", graph.burn())
+end