Class: SocketSwitcher::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/socket_switcher/device.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(port, number) ⇒ Device

Returns a new instance of Device.



2
3
4
5
# File 'lib/socket_switcher/device.rb', line 2

def initialize(port, number)
  @port   = port
  @number = number
end

Instance Attribute Details

#numberObject (readonly)

Returns the value of attribute number.



9
10
11
# File 'lib/socket_switcher/device.rb', line 9

def number
  @number
end

#portObject (readonly)

Returns the value of attribute port.



7
8
9
# File 'lib/socket_switcher/device.rb', line 7

def port
  @port
end

Instance Method Details

#offObject



15
16
17
# File 'lib/socket_switcher/device.rb', line 15

def off
  @port.__send__(:set_state, self, 0)
end

#onObject



11
12
13
# File 'lib/socket_switcher/device.rb', line 11

def on
  @port.__send__(:set_state, self, 1)
end

#to_sObject Also known as: inspect



19
20
21
# File 'lib/socket_switcher/device.rb', line 19

def to_s
  "#<#{self.class} number=#{number}>"
end