Sha256: d0c590fb4938dfe70e5d45195f680875bae73c65568dc1958613f2448e6f52a2
Contents?: true
Size: 818 Bytes
Versions: 1
Compression:
Stored size: 818 Bytes
Contents
require 'constructor' class AnalogIo #:nodoc: constructor :minilab_hardware, :result_verifier def read_analog(channel) check_channel_range(channel, 0, 7) result = @minilab_hardware.read_analog(channel) @result_verifier.verify(result, "read_analog") result[:value] end def write_analog(channel, volts) check_channel_range(channel, 0, 1) unless (0.0 .. 5.0) === volts raise "#{volts} volts is out of range for this device; Only voltage between 0.0 and 5.0 is supported." end result = @minilab_hardware.write_analog(channel, volts) @result_verifier.verify(result, "write_analog") end private def check_channel_range(channel, low, high) raise "Channel #{channel} is out of range." unless (low..high) === channel end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
minilab-1.0.0-mswin32 | lib/analog_io.rb |