Module: Rubyipmi::SensorsMixin
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *_args, &_block) ⇒ Object
36
37
38
39
40
41
42
|
# 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
|
Instance Method Details
#count ⇒ Object
12
13
14
|
# File 'lib/rubyipmi/commands/mixins/sensors_mixin.rb', line 12
def count
list.count
end
|
#fanlist(refreshdata = false) ⇒ Object
returns a hash of fan sensors where the key is fan name and value is the sensor
21
22
23
24
|
# 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 ⇒ Object
8
9
10
|
# File 'lib/rubyipmi/commands/mixins/sensors_mixin.rb', line 8
def list
@sensors ||= parse(getsensors)
end
|
#names ⇒ Object
16
17
18
|
# File 'lib/rubyipmi/commands/mixins/sensors_mixin.rb', line 16
def names
list.keys
end
|
#refresh ⇒ Object
3
4
5
6
|
# File 'lib/rubyipmi/commands/mixins/sensors_mixin.rb', line 3
def refresh
@sensors = nil
list
end
|
#templist(refreshdata = false) ⇒ Object
returns a hash of sensors where each key is the name of the sensor and the value is the sensor
27
28
29
30
31
32
|
# 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
|