Class: Avalon::Switch
- Inherits:
-
Object
- Object
- Avalon::Switch
- Defined in:
- lib/avalon/switch.rb
Overview
Encapsulates DLI Web Power Switch
Instance Method Summary collapse
-
#initialize(user, pass, ip, outlet) ⇒ Switch
constructor
A new instance of Switch.
- #off ⇒ Object
- #on ⇒ Object
Constructor Details
#initialize(user, pass, ip, outlet) ⇒ Switch
Returns a new instance of Switch.
6 7 8 9 |
# File 'lib/avalon/switch.rb', line 6 def initialize user, pass, ip, outlet @user, @pass, @ip, @outlet = user, pass, ip, outlet raise 'Please install curl: sudo apt-get install curl' if `which curl`.empty? end |
Instance Method Details
#off ⇒ Object
15 16 17 |
# File 'lib/avalon/switch.rb', line 15 def off `curl -s http://#{@user}:#{@pass}@#{@ip}/outlet?#{@outlet}=OFF` end |
#on ⇒ Object
11 12 13 |
# File 'lib/avalon/switch.rb', line 11 def on `curl -s http://#{@user}:#{@pass}@#{@ip}/outlet?#{@outlet}=ON` end |