class Spty::Command::VolumeCommand
Constants
- ASCRIPT_PLAYER_VOLUME_DOWN
- ASCRIPT_PLAYER_VOLUME_SET
- ASCRIPT_PLAYER_VOLUME_STATUS
- ASCRIPT_PLAYER_VOLUME_UP
Public Class Methods
call(options, _)
click to toggle source
# File lib/spty/commands/volume_command.rb, line 3 def self.call(options, _) return unless running? action = options.shift # call status if no sub command was called. action = 'status' if action.nil? # if sub command is number, trigger volume set with the number. if action =~ /\A\d+\z/ options = action.to_i action = 'level' end begin send(action.to_sym, options) rescue NameError => _e puts "unknown volume command #{action}" end end
down(_options)
click to toggle source
# File lib/spty/commands/volume_command.rb, line 57 def self.down(_options) Spty::AppleScriptRunner.call(ASCRIPT_PLAYER_VOLUME_DOWN) status end
level(options)
click to toggle source
# File lib/spty/commands/volume_command.rb, line 65 def self.level(options) if options < 0 || options > 100 puts 'volume level should be between 0 to 100' return end script = format(ASCRIPT_PLAYER_VOLUME_SET, level: options) Spty::AppleScriptRunner.call(script) status end
status(_options = nil)
click to toggle source
# File lib/spty/commands/volume_command.rb, line 27 def self.status(_options = nil) current_vol = Spty::AppleScriptRunner.call(ASCRIPT_PLAYER_VOLUME_STATUS) puts "volume is at #{current_vol}" end
up(_options)
click to toggle source
# File lib/spty/commands/volume_command.rb, line 42 def self.up(_options) Spty::AppleScriptRunner.call(ASCRIPT_PLAYER_VOLUME_UP) status end