Class: Anyplayer::Selector

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSelector

Returns a new instance of Selector.



18
19
20
21
# File 'lib/anyplayer/selector.rb', line 18

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

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



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

def errors
  @errors
end

#verboseObject

Returns the value of attribute verbose.



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

def verbose
  @verbose
end

Instance Method Details

#playerObject

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



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/anyplayer/selector.rb', line 24

def player
  PLAYERS.each do |player|
    player_load(player) || next

    instance = player_class(player).new
    player_on_platform?(instance) || next

    return instance if player_launched?(instance)
  end
  nil
end