aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile4
-rw-r--r--Gemfile.lock15
-rw-r--r--ramaskrik-program.rb23
3 files changed, 42 insertions, 0 deletions
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..4592615
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,4 @@
+# frozen_string_literal: true
+source "https://rubygems.org"
+
+gem "nokogiri"
diff --git a/Gemfile.lock b/Gemfile.lock
new file mode 100644
index 0000000..d6f0963
--- /dev/null
+++ b/Gemfile.lock
@@ -0,0 +1,15 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ mini_portile2 (2.3.0)
+ nokogiri (1.8.4)
+ mini_portile2 (~> 2.3.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ nokogiri
+
+BUNDLED WITH
+ 1.16.1
diff --git a/ramaskrik-program.rb b/ramaskrik-program.rb
new file mode 100644
index 0000000..0ca62e2
--- /dev/null
+++ b/ramaskrik-program.rb
@@ -0,0 +1,23 @@
+require 'date'
+require 'nokogiri'
+require 'open-uri'
+
+class Movie
+ attr_reader :title, :start_time, :end_time, :venue
+
+ def initialize(node)
+ @title = node.css("h4").text.strip
+ @start_time = DateTime.parse(node.css(".date").attribute('title').value)
+ @end_time = DateTime.parse(@start_time.strftime('%F') + node.css(".prgtype-endTime").text.strip.sub(/\w+/, ''))
+ @end_time += 1 if @end_time < @start_time
+ @venue = node.css(".place").text.strip
+ end
+
+ def to_s
+ "#{title} #{start_time} - #{end_time}, #{venue}"
+ 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