Class: Unified2::Sensor
- Inherits:
-
Object
- Object
- Unified2::Sensor
- Defined in:
- lib/unified2/sensor.rb
Instance Attribute Summary collapse
-
#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
A new instance of Sensor.
- #update(attributes = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Sensor
Returns a new instance of Sensor.
7 8 9 10 11 12 |
# File 'lib/unified2/sensor.rb', line 7 def initialize(={}) @id = [:id] || 0 @name = [:name] || "" @hostname ||= Socket.gethostname @interface ||= [:interface] || nil end |
Instance Attribute Details
#hostname ⇒ Object
Returns the value of attribute hostname.
4 5 6 |
# File 'lib/unified2/sensor.rb', line 4 def hostname @hostname end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/unified2/sensor.rb', line 4 def id @id end |
#interface ⇒ Object
Returns the value of attribute interface.
4 5 6 |
# File 'lib/unified2/sensor.rb', line 4 def interface @interface end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/unified2/sensor.rb', line 4 def name @name end |
Instance Method Details
#update(attributes = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/unified2/sensor.rb', line 14 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 |