Class: LinkScout::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/link_scout/runner.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  success: 200,
  limit: 10,
  follow: true
}

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Runner

Returns a new instance of Runner.



9
10
11
# File 'lib/link_scout/runner.rb', line 9

def initialize(args)
  @args = args
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/link_scout/runner.rb', line 13

def run
  case
  when single?(@args)
    @options = merge_defaults(@args[1])
    @options[:url] = @args[0]
    run_single
  when single_hash?(@args)
    @options = merge_defaults(@args[0])
    run_single
  when multiple_shared?(@args)
    @options = merge_defaults(@args[1])
    run_multiple_shared(@args[0])
  when multiple_individual?(@args)
    run_multiple(@args[0])
  else
    raise InvalidUsageError,  'Invalid usage of LinkScout::run. Please consult the README for help'
  end
end