Class: Commands::Play

Inherits:
Object
  • Object
show all
Defined in:
lib/commands/play.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, settings) ⇒ Play

Returns a new instance of Play.



3
4
5
# File 'lib/commands/play.rb', line 3

def initialize(args, settings)
  @app = args.first || settings.get('default_player')
end

Class Method Details

.matchesObject



21
22
23
# File 'lib/commands/play.rb', line 21

def self.matches
  ['play', 'play my music']
end

Instance Method Details

#goObject



7
8
9
10
11
# File 'lib/commands/play.rb', line 7

def go
  `osascript -e 'tell application "#{@app}" to launch'`
  sleep 1
  `osascript -e 'tell application "#{@app}" to play'`
end

#media?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/commands/play.rb', line 17

def media?
  false
end

#respondObject



13
14
15
# File 'lib/commands/play.rb', line 13

def respond
  "Now playing: #{`osascript -e 'tell application "#{@app}" to get the name of the current track'`}".chomp rescue ""
end