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.



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

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

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



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

def errors
  @errors
end

#verboseObject

Returns the value of attribute verbose.



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

def verbose
  @verbose
end

Instance Method Details

#playerObject

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



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

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

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

    if player_launched?(instance)
      return instance
    end
  end
  nil
end