Skip to content

Instantly share code, notes, and snippets.

@oparrish
Last active December 26, 2015 08:49
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 oparrish/7124851 to your computer and use it in GitHub Desktop.
Save oparrish/7124851 to your computer and use it in GitHub Desktop.
Ruby script to format a CUE sheet as HTML output
require 'rubycue'
require 'optparse'
options = {}
opts = OptionParser.new do |opts|
opts.on("-c", "--cue PATH", "Path to chesheet file") do |cue_file|
options[:cue] = cue_file
end
end
opts.parse!
cuesheet = RubyCue::Cuesheet.new(File.read(options[:cue]))
cuesheet.parse!
html="<ol>"
cuesheet.songs.each do |song|
hour = song[:index].minutes / 60
hour = hour.floor
minutes = (song[:index].minutes - hour * 60).floor
minutes = '%02d' % minutes
seconds = '%02d' % song[:index].seconds
if hour == 0
html << "<li>#{minutes}:#{seconds} #{song[:performer]} - #{song[:title]}</li>"
else
html << "<li>#{hour}:#{minutes}:#{seconds} #{song[:performer]} - #{song[:title]}</li>"
end
end
html << "</ol>"
puts html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment