class TellStickR::Device
Attributes
id[R]
model[R]
name[R]
protocol[R]
Public Class Methods
discover()
click to toggle source
# File lib/tellstickr/device.rb, line 38 def self.discover nr_of_devices = TellStickR::Core.tdGetNumberOfDevices i = 0 devices = [] while(i < nr_of_devices) do id = TellStickR::Core.tdGetDeviceId(i) name = TellStickR::Core.tdGetName(i) protocol = TellStickR::Core.tdGetProtocol(i) model = TellStickR::Core.tdGetModel(i) devices << Device.new(id, name, protocol, model) i += 1 end devices end
new(id, name, protocol, model)
click to toggle source
# File lib/tellstickr/device.rb, line 7 def initialize(id, name, protocol, model) @id = id @name = name @protocol = protocol @model = model end
Public Instance Methods
bell()
click to toggle source
# File lib/tellstickr/device.rb, line 32 def bell result = TellStickR::Core.tdBell(@id) return true if result == TellStickR::Core::TELLSTICK_SUCCESS raise TellStickR::Error.new(result) end
learn()
click to toggle source
# File lib/tellstickr/device.rb, line 14 def learn result = TellStickR::Core.tdLearn(@id) return true if result == TellStickR::Core::TELLSTICK_SUCCESS raise TellStickR::Error.new(result) end
off()
click to toggle source
# File lib/tellstickr/device.rb, line 26 def off result = TellStickR::Core.tdTurnOff(@id) return true if result == TellStickR::Core::TELLSTICK_SUCCESS raise TellStickR::Error.new(result) end
on()
click to toggle source
# File lib/tellstickr/device.rb, line 20 def on result = TellStickR::Core.tdTurnOn(@id) return true if result == TellStickR::Core::TELLSTICK_SUCCESS raise TellStickR::Error.new(result) end