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.
-
#to_s ⇒ String
To String.
-
#update(attributes = {}) ⇒ Object
Update.
Constructor Details
#initialize(options = {}) ⇒ Sensor
Initialize sensor object
21 22 23 24 25 26 27 |
# File 'lib/unified2/sensor.rb', line 21 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.
10 11 12 |
# File 'lib/unified2/sensor.rb', line 10 def checksum @checksum end |
#hostname ⇒ Object
Returns the value of attribute hostname.
10 11 12 |
# File 'lib/unified2/sensor.rb', line 10 def hostname @hostname end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/unified2/sensor.rb', line 10 def id @id end |
#interface ⇒ Object
Returns the value of attribute interface.
10 11 12 |
# File 'lib/unified2/sensor.rb', line 10 def interface @interface end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/unified2/sensor.rb', line 10 def name @name end |
Instance Method Details
#update(attributes = {}) ⇒ Object
Update
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/unified2/sensor.rb', line 48 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 |