Class: TellStickR::Device
- Inherits:
-
Object
- Object
- TellStickR::Device
- Defined in:
- lib/tellstickr/device.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
Class Method Summary collapse
Instance Method Summary collapse
- #bell ⇒ Object
-
#initialize(id, name, protocol, model) ⇒ Device
constructor
A new instance of Device.
- #learn ⇒ Object
- #off ⇒ Object
- #on ⇒ Object
Constructor Details
#initialize(id, name, protocol, model) ⇒ Device
Returns a new instance of Device.
7 8 9 10 11 12 |
# File 'lib/tellstickr/device.rb', line 7 def initialize(id, name, protocol, model) @id = id @name = name @protocol = protocol @model = model end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/tellstickr/device.rb', line 5 def id @id end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/tellstickr/device.rb', line 5 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/tellstickr/device.rb', line 5 def name @name end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
5 6 7 |
# File 'lib/tellstickr/device.rb', line 5 def protocol @protocol end |
Class Method Details
.discover ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# 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 |
Instance Method Details
#bell ⇒ Object
32 33 34 35 36 |
# 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 ⇒ Object
14 15 16 17 18 |
# 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 ⇒ Object
26 27 28 29 30 |
# 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 ⇒ Object
20 21 22 23 24 |
# 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 |