Class: Pling::Device
- Inherits:
-
Object
- Object
- Pling::Device
- Defined in:
- lib/pling/device.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
The device identifier.
-
#type ⇒ Object
The device type.
Instance Method Summary collapse
-
#deliver(message) ⇒ Object
Delivers the given message using an appropriate gateway.
-
#initialize(attributes = {}) ⇒ Device
constructor
Creates a new Pling::Device instance with the given identifier and type.
-
#to_pling_device ⇒ Pling::Device
Returns the object itself as it is already a Pling::Device.
-
#valid? ⇒ Boolean
A device is valid if it has a type and an identifier.
Constructor Details
#initialize(attributes = {}) ⇒ Device
Creates a new Pling::Device instance with the given identifier and type
36 37 38 39 40 41 |
# File 'lib/pling/device.rb', line 36 def initialize(attributes = {}) attributes.each_pair do |key, value| method = "#{key}=" send(method, value) if respond_to?(method) end end |
Instance Attribute Details
#identifier ⇒ Object #identifier=(identifier) ⇒ Object
The device identifier
10 11 12 |
# File 'lib/pling/device.rb', line 10 def identifier @identifier end |
#type ⇒ Object #type=(type) ⇒ Object
The device type
23 24 25 |
# File 'lib/pling/device.rb', line 23 def type @type end |
Instance Method Details
#deliver(message) ⇒ Object
Delivers the given message using an appropriate gateway.
55 56 57 |
# File 'lib/pling/device.rb', line 55 def deliver() Pling.deliver(, self) end |
#to_pling_device ⇒ Pling::Device
Returns the object itself as it is already a Pling::Device.
63 64 65 |
# File 'lib/pling/device.rb', line 63 def to_pling_device self end |
#valid? ⇒ Boolean
A device is valid if it has a type and an identifier.
47 48 49 |
# File 'lib/pling/device.rb', line 47 def valid? !!(type && identifier) end |