class Cuegrowler::Growler
Public Class Methods
new(player, tracklist)
click to toggle source
# File lib/cuegrowler.rb, line 86 def initialize(player, tracklist) @current_position = -Float::INFINITY @player = player @tracklist = tracklist end
Public Instance Methods
loop_forever!()
click to toggle source
# File lib/cuegrowler.rb, line 92 def loop_forever! loop do tick sleep 2 end end
tick()
click to toggle source
# File lib/cuegrowler.rb, line 99 def tick update_position tracklist = @tracklist.get new_song = tracklist.reverse.find { |track| @last_position < track[:time] && track[:time] <= @current_position } notify(new_song) if new_song end
Protected Instance Methods
notify(new_song)
click to toggle source
# File lib/cuegrowler.rb, line 114 def notify(new_song) Growl.notify new_song[:text], name: 'cuegrowler', title: 'New Track' puts "\n[#{Time.now}]" puts new_song[:text] end
update_position()
click to toggle source
# File lib/cuegrowler.rb, line 109 def update_position @last_position = @current_position @current_position = @player.get_player_position end