Class: Sensors::Subfeature

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(feature, pointer) ⇒ Subfeature

Returns a new instance of Subfeature.



34
35
36
37
38
# File 'lib/sensors/subfeature.rb', line 34

def initialize (feature, pointer)
  @chip    = feature.chip
  @feature = feature
  @value   = pointer.is_a?(C::Subfeature) ? pointer : C::Subfeature.new(pointer)
end

Instance Attribute Details

#chipObject (readonly)

Returns the value of attribute chip.



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

def chip
  @chip
end

Instance Method Details

#to_ffiObject



60
61
62
# File 'lib/sensors/subfeature.rb', line 60

def to_ffi
  number
end

#valueObject



46
47
48
49
50
51
52
# File 'lib/sensors/subfeature.rb', line 46

def value
  FFI::MemoryPointer.new(:double).tap {|result|
    C::sensors_get_value(chip.to_ffi, to_ffi, result)

    break result.typecast(:double)
  }
end

#value=(value) ⇒ Object



54
55
56
# File 'lib/sensors/subfeature.rb', line 54

def value= (value)
  C::sensors_set_value(chip.to_ffi, to_ffi, value)
end