Class: Unified2::Sensor
- Inherits:
-
Object
- Object
- Unified2::Sensor
- Defined in:
- lib/unified2/sensor.rb
Overview
Sensor
Instance Attribute Summary collapse
-
#checksum ⇒ Object
Returns the value of attribute checksum.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#id ⇒ Object
Returns the value of attribute id.
-
#interface ⇒ Object
Returns the value of attribute interface.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Sensor
constructor
Initialize sensor object.
-
#update(attributes = {}) ⇒ Object
Update.
Constructor Details
#initialize(options = {}) ⇒ Sensor
Initialize sensor object
18 19 20 21 22 23 24 |
# File 'lib/unified2/sensor.rb', line 18 def initialize(={}) @id = [:id] || 0 @name = [:name] || "" @hostname ||= Socket.gethostname @interface ||= [:interface] || nil @checksum = nil end |
Instance Attribute Details
#checksum ⇒ Object
Returns the value of attribute checksum.
7 8 9 |
# File 'lib/unified2/sensor.rb', line 7 def checksum @checksum end |
#hostname ⇒ Object
Returns the value of attribute hostname.
7 8 9 |
# File 'lib/unified2/sensor.rb', line 7 def hostname @hostname end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/unified2/sensor.rb', line 7 def id @id end |
#interface ⇒ Object
Returns the value of attribute interface.
7 8 9 |
# File 'lib/unified2/sensor.rb', line 7 def interface @interface end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/unified2/sensor.rb', line 7 def name @name end |
Instance Method Details
#update(attributes = {}) ⇒ Object
Update
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/unified2/sensor.rb', line 36 def update(attributes={}) return self if attributes.empty? attributes.each do |key, value| next unless self.respond_to?(key.to_sym) instance_variable_set(:"@#{key}", value) end self end |