Class: PlayerMessageObserver
Instance Method Summary
collapse
#initialize
Constructor Details
This class inherits a constructor from Site::Observer
Instance Method Details
#update(time, message) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/terminal_player/site.rb', line 73
def update(time, message)
if message['ICY']
begin
m = message.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
song = m[/StreamTitle='(.*?)';/, 1]
rescue => e
write "error '#{e}' with ICY message: #{m}"
end
@site.songs << song
@site.song_changed
elsif message['SPOTTY']
@site.songs << message.gsub(/SPOTTY /, '')
@site.song_changed
elsif message['Cache ']
write message
end
end
|
#write(message) ⇒ Object
91
92
93
|
# File 'lib/terminal_player/site.rb', line 91
def write(message)
print "\n<site-debug> #{message}\r"
end
|