Class: Sensors::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/sensors/feature.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#chipObject (readonly)

Returns the value of attribute chip.



32
33
34
# File 'lib/sensors/feature.rb', line 32

def chip
  @chip
end

#labelObject (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

#subfeaturesObject



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_ffiObject



63
64
65
# File 'lib/sensors/feature.rb', line 63

def to_ffi
  @value
end