Module: MsgHandler
- Included in:
- MpdHandler
- Defined in:
- lib/msg_handler.rb
Overview
encoding: utf-8
Instance Method Summary (collapse)
- - (Object) album(song)
- - (Object) beutify(song)
- - (Object) is_stream(song)
- - (Object) message(title, artist, album, date = nil)
- - (Object) stream(song)
Instance Method Details
- (Object) album(song)
43 44 45 46 47 |
# File 'lib/msg_handler.rb', line 43 def album(song) date = "~#{song.date}~" || nil msg = (song.title,song.artist,song.album,date) return msg end |
- (Object) beutify(song)
5 6 7 |
# File 'lib/msg_handler.rb', line 5 def beutify(song) is_stream(song) ? stream(song) : album(song) end |
- (Object) is_stream(song)
9 10 11 |
# File 'lib/msg_handler.rb', line 9 def is_stream(song) song.file.include?("http://") end |
- (Object) message(title, artist, album, date = nil)
49 50 51 52 53 54 |
# File 'lib/msg_handler.rb', line 49 def (title,artist,album,date=nil) title = title.titleize.strip artist = artist.titleize.strip album = album.strip msg = [title,"by",artist,"on",album,date].join(" ") end |
- (Object) stream(song)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/msg_handler.rb', line 13 def stream(song) case song.name when /More Fm/ stream = "More Fm" artist, title = song.title.split(" - ") title = "News" if artist == "FSNHeadlines" msg = (title,artist,stream) when /Retro Radio Csikszereda/ stream = "Retro Radio" if song.title.nil? || song.title.empty? title = artist = "...?..." else artist, title = song.title.split(" - ") end msg = (title,artist,stream) when /ProFM/ stream = song.name if song.title.nil? || song.title.empty? title = artist = "...?..." else title, artist = song.title.match(/(.*)\((.*)\)/).captures end msg = (title,artist,stream) else msg = "...?..." msg = song.name unless song.name.nil? || song.name.empty? end return msg end |