Skip to content

Instantly share code, notes, and snippets.

@schatteleyn
Created December 6, 2012 13:19
Show Gist options
  • Save schatteleyn/4224402 to your computer and use it in GitHub Desktop.
Save schatteleyn/4224402 to your computer and use it in GitHub Desktop.
Do an easy line-up
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