Created
December 6, 2012 13:19
-
-
Save schatteleyn/4224402 to your computer and use it in GitHub Desktop.
Do an easy line-up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'trollop' | |
opts = Trollop.options do | |
banner <<-EOS | |
This programs help you to do a running order. Use it like this: | |
ruby lineup.rb -b Band "Best Band Ever" -t 30 75 -e 21 25 -s 20 | |
Band | |
Set: 21:25 - 21:55 | |
Best Band Ever | |
Set: 22:15 - 23:30 | |
If every band have the same set duration, just pass it once, and it will works just fine. | |
The options are: | |
EOS | |
opt :bands, 'an array with name of bands', type: :strings | |
opt :time, 'an array of set duration in minutes', type: :ints | |
opt :beginning, 'Beginning of the shows', type: :ints, :default => [20, 30] | |
opt :set, 'Duration of set changes', :default => 15 | |
end | |
def lineup(band, set_b, delay, h) | |
set_end = set_b + h[band] * 60 | |
puts band | |
puts "Set: #{set_b.hour}:#{"%02d" % set_b.min.to_i} - #{set_end.hour}:#{"%02d" % set_end.min.to_i}" | |
h.shift | |
next_show = set_end + delay * 60 | |
lineup(h.first.first, next_show, delay, h) if !h.empty? | |
end | |
set_time = opts[:time] | |
bands = opts[:bands] | |
if set_time.length != bands.length | |
(bands.length - 1).times { |nb| set_time.push(set_time.first) } | |
end | |
h = Hash[bands.zip(set_time)] | |
hour = opts[:beginning][0] | |
minute = opts[:beginning][1] | |
time = Time.gm(2000,1,1, hour, minute) | |
lineup(bands.first, time, opts[:set], h) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment