class RangeScan::CLI

Public Class Methods

exit_on_failure?() click to toggle source
# File lib/rangescan/cli.rb, line 39
def exit_on_failure?
  true
end

Public Instance Methods

scan(ip_with_subnet_mask, regexp = ".") click to toggle source
# File lib/rangescan/cli.rb, line 17
def scan(ip_with_subnet_mask, regexp = ".")
  symbolized_options = symbolize_hash_keys(options)
  range = Range.new(ip_with_subnet_mask)

  scanner = Scanner.new(**symbolized_options)
  results = scanner.scan(range.to_a)

  matcher = Matcher.new(regexp)
  filtered = matcher.filter(results)

  puts JSON.pretty_generate(filtered)
end
symbolize_hash_keys(hash) click to toggle source
# File lib/rangescan/cli.rb, line 33
def symbolize_hash_keys(hash)
  hash.map { |k, v| [k.to_sym, v] }.to_h
end