Sha256: b42b7811ccc9a4f817fdc932bbfe962040a70b37b53a5de993ff0f7c6b48e1f3
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
require 'thor' require 'pp' require 'prologix_gpib' require 'terminal-table' module PrologixGpib class CLI < Thor desc 'list', 'List all connected controllers' def list if controllers_connected? table = Terminal::Table.new do |t| t.title = 'Prologix Controllers' t.headings = %w[index Controller Version Path] PrologixGpib.usb_paths.each.with_index do |path, index| device = PrologixGpib::UsbController.new(path) str = device.version.split('version') t.add_row [index.to_s, str[0], str[1], path] end end puts table else puts 'No Prologix Controllers available.' end end desc 'info', 'Display Controller information' option :path, alias: :p def info return unless controllers_connected? paths = options[:path].nil? ? PrologixGpib.usb_paths : [options[:path]] paths.each do |path| hash = PrologixGpib::UsbController.new(path).config puts "\n #{titleise hash.delete(:device_name)}" puts "\tPath: #{path}" hash.each { |k, v| puts "\t#{titleise(k)}: #{v}" } end end private def controllers_connected? PrologixGpib.usb_paths.count >= 1 end def titleise(string) string.to_s.split('_').map(&:capitalize).join(' ') end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
prologix_gpib-0.4.4 | lib/prologix_gpib/cli.rb |
prologix_gpib-0.4.3 | lib/prologix_gpib/cli.rb |