module Rubyipmi::SensorsMixin
Public Instance Methods
count()
click to toggle source
# File lib/rubyipmi/commands/mixins/sensors_mixin.rb, line 12 def count list.count end
fanlist(refreshdata = false)
click to toggle source
returns a hash of fan sensors where the key is fan name and value is the sensor
# File lib/rubyipmi/commands/mixins/sensors_mixin.rb, line 21 def fanlist(refreshdata = false) refresh if refreshdata list.each_with_object({}) { |(name, sensor), flist| flist[name] = sensor if name =~ /.*fan.*/ } end
list()
click to toggle source
# File lib/rubyipmi/commands/mixins/sensors_mixin.rb, line 8 def list @sensors ||= parse(getsensors) end
names()
click to toggle source
# File lib/rubyipmi/commands/mixins/sensors_mixin.rb, line 16 def names list.keys end
refresh()
click to toggle source
# File lib/rubyipmi/commands/mixins/sensors_mixin.rb, line 3 def refresh @sensors = nil list end
templist(refreshdata = false)
click to toggle source
returns a hash of sensors where each key is the name of the sensor and the value is the sensor
# File lib/rubyipmi/commands/mixins/sensors_mixin.rb, line 27 def templist(refreshdata = false) refresh if refreshdata list.each_with_object({}) do |(name, sensor), tlist| tlist[name] = sensor if (sensor[:unit] =~ /.*degree.*/ || name =~ /.*temp.*/) end end
Private Instance Methods
method_missing(method, *_args, &_block)
click to toggle source
# File lib/rubyipmi/commands/mixins/sensors_mixin.rb, line 36 def method_missing(method, *_args, &_block) if !list.key?(method.to_s) raise NoMethodError else list[method.to_s] end end
parse(data)
click to toggle source
# File lib/rubyipmi/commands/mixins/sensors_mixin.rb, line 44 def parse(data) return {} if data.nil? data.lines.each_with_object({}) do |line, sensorlist| # skip the header sensor = sensor_class.new(line) sensorlist[sensor[:name]] = sensor end end