cmus 2.0.4.3 → 2.0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cmus/controller/status.rb +12 -0
- data/lib/cmus/controller/toggle.rb +46 -2
- data/lib/cmus/version.rb +1 -1
- metadata +1 -1
@@ -55,6 +55,18 @@ class Status
|
|
55
55
|
when :set
|
56
56
|
name, data = data.split ' ', 2
|
57
57
|
|
58
|
+
data = if data == 'false'
|
59
|
+
false
|
60
|
+
elsif data == 'true'
|
61
|
+
true
|
62
|
+
elsif (Integer(data) rescue false)
|
63
|
+
data.to_i
|
64
|
+
elsif (Float(data) rescue false)
|
65
|
+
data.to_f
|
66
|
+
else
|
67
|
+
data
|
68
|
+
end
|
69
|
+
|
58
70
|
@settings.send "#{name}=", data
|
59
71
|
end
|
60
72
|
}
|
@@ -17,19 +17,63 @@ class Toggle
|
|
17
17
|
@controller = controller
|
18
18
|
end
|
19
19
|
|
20
|
+
def toggle (name)
|
21
|
+
controller.puts "toggle #{name}"
|
22
|
+
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
def on (name)
|
27
|
+
unless controller.status.settings.send(name)
|
28
|
+
controller.puts "toggle #{name}"
|
29
|
+
end
|
30
|
+
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def off (name)
|
35
|
+
if controller.status.settings.send(name)
|
36
|
+
controller.puts "toggle #{name}"
|
37
|
+
end
|
38
|
+
|
39
|
+
self
|
40
|
+
end
|
41
|
+
|
20
42
|
# toggle the repeat status
|
21
43
|
def repeat
|
22
|
-
|
44
|
+
toggle :Repeat
|
45
|
+
end
|
46
|
+
|
47
|
+
# enable repeat
|
48
|
+
def repeat!
|
49
|
+
on :Repeat
|
50
|
+
end
|
51
|
+
|
52
|
+
# disable repeat
|
53
|
+
def no_repeat!
|
54
|
+
off :Repeat
|
23
55
|
end
|
24
56
|
|
25
57
|
# toggle the shuffle status
|
26
58
|
def shuffle
|
27
|
-
|
59
|
+
toggle :Shuffle
|
60
|
+
end
|
61
|
+
|
62
|
+
# enable shuffle
|
63
|
+
def shuffle!
|
64
|
+
on :Shuffle
|
65
|
+
end
|
66
|
+
|
67
|
+
# disable shuffle
|
68
|
+
def no_shuffle!
|
69
|
+
off :Shuffle
|
28
70
|
end
|
29
71
|
|
30
72
|
# toggle the pause status
|
31
73
|
def pause
|
32
74
|
controller.puts 'player-pause'
|
75
|
+
|
76
|
+
self
|
33
77
|
end
|
34
78
|
end
|
35
79
|
|
data/lib/cmus/version.rb
CHANGED