尝试通过命令行选项从文件中打印行时出现此错误
no implicit conversion of true into String (TypeError)
from threat_detection.rb:64:in 'new'
from threat_detection.rb:64:in '<main>'
如果我使用文件名而不是options[:config_file]
它会按预期打印文件的行。
if options[:config_file]
File.new(options[:config_file], 'r').each { |params| puts params }
end
if options[:host_file]
File.new(options[:host_file], 'r').each { |host| puts host }
end