Class: Site
Defined Under Namespace
Classes: Observer
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#current_channel ⇒ Object
readonly
Returns the value of attribute current_channel.
-
#is_di_plus ⇒ Object
readonly
Returns the value of attribute is_di_plus.
-
#is_mplayer ⇒ Object
readonly
Returns the value of attribute is_mplayer.
-
#is_spotify ⇒ Object
readonly
Returns the value of attribute is_spotify.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#player ⇒ Object
Returns the value of attribute player.
-
#songs ⇒ Object
Returns the value of attribute songs.
Instance Method Summary collapse
-
#initialize(options, name) ⇒ Site
constructor
A new instance of Site.
- #play ⇒ Object
- #song_changed ⇒ Object
Constructor Details
#initialize(options, name) ⇒ Site
Returns a new instance of Site.
9 10 11 12 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 42 |
# File 'lib/terminal_player/site.rb', line 9 def initialize(, name) @name = name @songs = [] @channels = [] [:cache] || [:cache] = 512 [:cache_min] || [:cache_min] = 30 [:url] || [:url] = '' if [:url].nil? || [:url].empty? fail "no :url in the options hash sent to Site" end @is_di_plus = [:di_plus] @is_spotify = ![:url]['spotify:'].nil? if @is_spotify @current_channel = spotify_type([:url]) else @current_channel = [:url].split('/').last @current_channel = @current_channel[0..@current_channel.index('.') - 1] end if @is_spotify @is_mplayer = false @player = SpotiphyPlayer.new() else @is_mplayer = true @player = Mplayer.new({cache: [:cache], cache_min: [:cache_min], url: [:url]}) end PlayerMessageObserver.new(self, @player) end |
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
7 8 9 |
# File 'lib/terminal_player/site.rb', line 7 def channels @channels end |
#current_channel ⇒ Object (readonly)
Returns the value of attribute current_channel.
7 8 9 |
# File 'lib/terminal_player/site.rb', line 7 def current_channel @current_channel end |
#is_di_plus ⇒ Object (readonly)
Returns the value of attribute is_di_plus.
7 8 9 |
# File 'lib/terminal_player/site.rb', line 7 def is_di_plus @is_di_plus end |
#is_mplayer ⇒ Object (readonly)
Returns the value of attribute is_mplayer.
7 8 9 |
# File 'lib/terminal_player/site.rb', line 7 def is_mplayer @is_mplayer end |
#is_spotify ⇒ Object (readonly)
Returns the value of attribute is_spotify.
7 8 9 |
# File 'lib/terminal_player/site.rb', line 7 def is_spotify @is_spotify end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/terminal_player/site.rb', line 7 def name @name end |
#player ⇒ Object
Returns the value of attribute player.
6 7 8 |
# File 'lib/terminal_player/site.rb', line 6 def player @player end |
#songs ⇒ Object
Returns the value of attribute songs.
6 7 8 |
# File 'lib/terminal_player/site.rb', line 6 def songs @songs end |
Instance Method Details
#play ⇒ Object
44 45 46 |
# File 'lib/terminal_player/site.rb', line 44 def play @player.play end |
#song_changed ⇒ Object
48 49 50 51 |
# File 'lib/terminal_player/site.rb', line 48 def song_changed changed notify_observers(Time.now, @songs) end |