class Unified2::Sensor
Attributes
checksum[RW]
hostname[RW]
id[RW]
interface[RW]
name[RW]
Public Class Methods
new(options={})
click to toggle source
Initialize sensor object
@param [Hash] options Sensor
hash attributes
@option options [Integer] :id Sensor
id @option options [String] :name Sensor
name @option options [String] :interface Sensor
interface
# File lib/unified2/sensor.rb, line 21 def initialize(options={}) @id = options[:id] || 0 @name = options[:name] || "" @hostname ||= Socket.gethostname @interface ||= options[:interface] || nil @checksum = nil end
Public Instance Methods
to_h()
click to toggle source
# File lib/unified2/sensor.rb, line 38 def to_h to_hash = { :name => name, :hostname => hostname, :checksum => checksum, :id => id, :interface => interface } end
to_s()
click to toggle source
update(attributes={})
click to toggle source
Update
@param [Hash] attributes Sensor
attributes
@option attributes [Integer] :id Sensor
id @option attributes [String] :hostname Sensor
hostname @option attributes [String] :name Sensor
name @option attributes [String] :interface Sensor
interface
# 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