Class: Anyplayer::Selector

Inherits:
Object
  • Object
show all
Defined in:
lib/anyplayer/selector.rb

Overview

The Selector is the tool that will find you the currently running player on your platform

Example:

selector = Anyplayer::Selector.new
selector.verbose = true
player = selector.player

Needs the PLAYERS constant to contain a list of players.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Selector

Returns a new instance of Selector.



15
16
17
18
# File 'lib/anyplayer/selector.rb', line 15

def initialize
  @verbose = false
  @errors = []
end

Instance Attribute Details

#errors ⇒ Object (readonly)

Returns the value of attribute errors.



13
14
15
# File 'lib/anyplayer/selector.rb', line 13

def errors
  @errors
end

#verbose ⇒ Object

Returns the value of attribute verbose.



12
13
14
# File 'lib/anyplayer/selector.rb', line 12

def verbose
  @verbose
end

Instance Method Details

#player ⇒ Object

Returns an instance of the first music player that's launched



21
22
23
24
25
26
27
28
# File 'lib/anyplayer/selector.rb', line 21

def player
  players_for_this_platform.each { |player|
    player_load(player) or next
    instance = player_class(player).new
    return instance if player_launched(instance)
  }
  nil
end