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_h ⇒ 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
#to_h ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/unified2/sensor.rb', line 38 def to_h to_hash = { :name => name, :hostname => hostname, :checksum => checksum, :id => id, :interface => interface } end |
#update(attributes = {}) ⇒ Object
Update
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/unified2/sensor.rb', line 58 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 |