class Cuegrowler::Tracklist::Cuesheet
Public Class Methods
new(filename)
click to toggle source
# File lib/cuegrowler.rb, line 49 def initialize(filename) @filename = filename @data = [] cuesheet = RubyCue::Cuesheet.new(open(filename).read) cuesheet.parse! cuesheet.songs.each_with_index do |song, index| time = song[:index].to_f text = "#{index + 1}. #{format time} #{song[:performer]} — #{song[:title]}" @data << { text: text, time: time } end end
Public Instance Methods
get()
click to toggle source
# File lib/cuegrowler.rb, line 65 def get @data end
to_s()
click to toggle source
# File lib/cuegrowler.rb, line 69 def to_s "From cuesheet #{@filename}" end
Private Instance Methods
format(time)
click to toggle source
# File lib/cuegrowler.rb, line 74 def format(time) hours, time = time.divmod(3600) minutes, seconds = time.divmod(60) "[%d:%02d:%02d]" % [hours, minutes, seconds] end