Class: Avalon::Switch

Inherits:
Object
  • Object
show all
Defined in:
lib/avalon/switch.rb

Overview

Encapsulates DLI Web Power Switch

Instance Method Summary collapse

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

#offObject



15
16
17
# File 'lib/avalon/switch.rb', line 15

def off
  `curl -s http://#{@user}:#{@pass}@#{@ip}/outlet?#{@outlet}=OFF`
end

#onObject



11
12
13
# File 'lib/avalon/switch.rb', line 11

def on
  `curl -s http://#{@user}:#{@pass}@#{@ip}/outlet?#{@outlet}=ON`
end