Class: Sonos::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/sonos/cli.rb

Instance Method Summary collapse

Instance Method Details

#destroy_alarm(alarm_id) ⇒ Object



87
88
89
# File 'lib/sonos/cli.rb', line 87

def destroy_alarm(alarm_id)
  speakers[0].destroy_alarm(alarm_id)
end

#devicesObject



7
8
9
10
11
# File 'lib/sonos/cli.rb', line 7

def devices
  system.devices.each do |device|
    puts device.name.ljust(20) + device.ip
  end
end

#disable_alarm(alarm_id) ⇒ Object



77
78
79
# File 'lib/sonos/cli.rb', line 77

def disable_alarm(alarm_id)
  speakers[0].disable_alarm(alarm_id)
end

#enable_alarm(alarm_id) ⇒ Object



72
73
74
# File 'lib/sonos/cli.rb', line 72

def enable_alarm(alarm_id)
  speakers[0].enable_alarm(alarm_id)
end

#groupsObject



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/sonos/cli.rb', line 41

def groups
  system.groups.each do |group|
    puts group.master_speaker.name.ljust(20) + group.master_speaker.ip

    group.slave_speakers.each do |speaker|
      puts speaker.name.rjust(10).ljust(20) + speaker.ip
    end

    puts "\n"
  end
end

#is_alarm_enabled?(alarm_id) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/sonos/cli.rb', line 67

def is_alarm_enabled?(alarm_id)
  puts speakers[0].is_alarm_enabled?(alarm_id)
end

#list_alarmsObject



62
63
64
# File 'lib/sonos/cli.rb', line 62

def list_alarms
  puts speakers[0].list_alarms
end

#party_modeObject



31
32
33
# File 'lib/sonos/cli.rb', line 31

def party_mode
  system.party_mode
end

#party_overObject



36
37
38
# File 'lib/sonos/cli.rb', line 36

def party_over
  system.party_over
end

#pause_allObject



21
22
23
# File 'lib/sonos/cli.rb', line 21

def pause_all
	system.pause_all
end

#play_allObject



26
27
28
# File 'lib/sonos/cli.rb', line 26

def play_all
  system.play_all
end

#set_alarm_volume(alarm_id, volume) ⇒ Object



82
83
84
# File 'lib/sonos/cli.rb', line 82

def set_alarm_volume(alarm_id, volume)
  speakers[0].set_alarm_volume(alarm_id, volume)
end

#speaker(name, command, *args) ⇒ Object



54
55
56
57
58
59
# File 'lib/sonos/cli.rb', line 54

def speaker(name, command, *args)
  speakers = system.speakers.select { |s| s.name.downcase == name.downcase }
  puts "Could not find speaker" and return if speakers.length == 0

  speakers.each { |s| s.send command, *args }
end

#speakersObject



14
15
16
17
18
# File 'lib/sonos/cli.rb', line 14

def speakers
  system.speakers.each do |speaker|
    puts speaker.name.ljust(20) + speaker.ip
  end
end