Class: PrologixGpib::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/prologix_gpib/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CLI

Returns a new instance of CLI.



9
10
11
12
# File 'lib/prologix_gpib/cli.rb', line 9

def initialize(*args)
  super
  @controllers = PrologixGpib::Finder.new.avaliable_controllers
end

Instance Method Details

#info(index) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/prologix_gpib/cli.rb', line 22

def info(index)
  return unless controllers_connected?

  controller_paths = @controllers.map { |k, v| v }.flatten

  path = controller_paths[index.to_i]
  hash = ip_address?(path) ? PrologixGpib::LanController.new(path).config : 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

#listObject



16
17
18
# File 'lib/prologix_gpib/cli.rb', line 16

def list
  puts controller_table(@controllers)
end