ruboty-toggle_switch 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/ruboty/handlers/toggle_switch.rb +2 -2
- data/lib/ruboty/toggle_switch/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c1220d0e943d1deb267ee35a62f685ca718b3c1
|
4
|
+
data.tar.gz: 2cd9d3eb95a92c74fc6aa8bec36400d4ba55c06d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d8ba2502e9c6379b6a336a17ffc1fd67d8e15d3ff30492b0c92a0fbb27e6c4e9323f74003035aa3463101f3e5701d093c8e51f8eb18d05c0dfc9d18f66fb4fd
|
7
|
+
data.tar.gz: 331d5b7c38afb1eb351d2b68bb208e0cf3bb3dc2b0fe85eb8cab173f78548a66db780ac0a017bea3cad9629a2e0e51e51b4244b046951be4e4451dd73d1b9b64
|
data/README.md
CHANGED
@@ -24,3 +24,13 @@ radio switch is now off.
|
|
24
24
|
> ruboty show radio switch status
|
25
25
|
radio switch is off.
|
26
26
|
```
|
27
|
+
|
28
|
+
## API
|
29
|
+
|
30
|
+
Use `Ruboty::ToggleSwitch::Storage` to get the state of switch from another handlers:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
storage = Ruboty::ToggleSwitch::Storage.new(robot.brain)
|
34
|
+
record = storage['switch']
|
35
|
+
record.status # => 'on' or 'off'
|
36
|
+
```
|
@@ -3,8 +3,8 @@ module Ruboty
|
|
3
3
|
class ToggleSwitch < Base
|
4
4
|
NAMESPACE = 'toggle_switch'
|
5
5
|
|
6
|
-
on(/toggle\s+(?<switch>.*)\s+(?<state>on|off)/, name: 'toggle', description: 'Toggle switch')
|
7
|
-
on(/show\s+(?<switch>.*)\s+status/, name: 'show', description: 'Show switch status')
|
6
|
+
on(/toggle\s+(?<switch>.*)\s+(?<state>on|off)\z/, name: 'toggle', description: 'Toggle switch')
|
7
|
+
on(/show\s+(?<switch>.*)\s+status\z/, name: 'show', description: 'Show switch status')
|
8
8
|
|
9
9
|
def toggle(message)
|
10
10
|
switch = message[:switch]
|