Skip to content

Instantly share code, notes, and snippets.

@elliotcm
Created June 2, 2012 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elliotcm/2859131 to your computer and use it in GitHub Desktop.
Save elliotcm/2859131 to your computer and use it in GitHub Desktop.
PvAvPvA film scheduler
require 'rubygems'
require 'active_support/core_ext/numeric'
require 'hirb'; extend Hirb::Console
INTERMISSION = 10.minutes
def print_times_for(films, start_time)
last_end_time = start_time - INTERMISSION
run = films.map do |film|
start_time = last_end_time + INTERMISSION
last_end_time = start_time + film[:running_time].minutes
{:title => film[:title], :start => start_time.strftime('%H:%M'), :end => last_end_time.strftime('%H:%M')}
end
table run, :fields => [:title, :start, :end]
end
puts "Saturday, 9 June 2012"
predator_films = [
{:title => 'Predator', :running_time => 107},
{:title => 'Predator 2', :running_time => 108},
{:title => 'AvP', :running_time => 100},
{:title => 'AvP 2', :running_time => 94},
{:title => 'Predators', :running_time => 107}
]
predator_start_time = Time.gm(2012, 6, 9, 12, 0)
print_times_for(predator_films, predator_start_time)
puts
puts "Sunday, 10 June 2012"
cinema_bullshit_padding = 45
alien_films = [
{:title => 'Prometheus', :running_time => 124 + cinema_bullshit_padding},
{:title => 'Alien', :running_time => 117},
{:title => 'Aliens', :running_time => 137},
{:title => 'Alien 3', :running_time => 114},
{:title => 'Alien Res', :running_time => 109}
]
prometheus_start_time = Time.gm(2012, 6, 10, 12, 0)
print_times_for(alien_films, prometheus_start_time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment