Class: Sensors::Feature
- Inherits:
-
Object
- Object
- Sensors::Feature
- Defined in:
- lib/sensors/feature.rb
Instance Attribute Summary collapse
-
#chip ⇒ Object
readonly
Returns the value of attribute chip.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
Instance Method Summary collapse
-
#initialize(chip, pointer) ⇒ Feature
constructor
A new instance of Feature.
- #subfeature(type) ⇒ Object
- #subfeatures ⇒ Object
- #to_ffi ⇒ Object
Constructor Details
#initialize(chip, pointer) ⇒ Feature
Returns a new instance of Feature.
34 35 36 37 38 39 |
# File 'lib/sensors/feature.rb', line 34 def initialize (chip, pointer) @chip = chip @value = pointer.is_a?(C::Feature) ? pointer : C::Feature.new(pointer) @label = C::sensors_get_label(chip.to_ffi, to_ffi) end |
Instance Attribute Details
#chip ⇒ Object (readonly)
Returns the value of attribute chip.
32 33 34 |
# File 'lib/sensors/feature.rb', line 32 def chip @chip end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
32 33 34 |
# File 'lib/sensors/feature.rb', line 32 def label @label end |
Instance Method Details
#subfeature(type) ⇒ Object
47 48 49 |
# File 'lib/sensors/feature.rb', line 47 def subfeature (type) Subfeature.new(self, C::sensors_get_subfeature(chip.to_ffi, to_ffi, C::SubfeatureType["#{feature.type}_#{type.downcase}".to_sym])) end |
#subfeatures ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/sensors/feature.rb', line 51 def subfeatures Enumerator.new do |e| number = FFI::MemoryPointer.new :int until (subfeature = C::sensors_get_all_subfeatures(chip.to_ffi, to_ffi, number)).null? e << Subfeature.new(self, subfeature) end end end |
#to_ffi ⇒ Object
63 64 65 |
# File 'lib/sensors/feature.rb', line 63 def to_ffi @value end |