Class: Brocli::Initiate

Inherits:
Thor
  • Object
show all
Includes:
Ping, Sanitizer
Defined in:
lib/brocli/cli.rb

Instance Method Summary collapse

Methods included from Ping

#ping

Methods included from Sanitizer

#sanitizer

Instance Method Details

#hit(url = Brocli::DEFAULT_URL, time_limit = Brocli::EXECUTION_TIME_LIMIT, time_interval = Brocli::TIME_INTERVAL) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/brocli/cli.rb', line 27

def hit(url = Brocli::DEFAULT_URL, time_limit = Brocli::EXECUTION_TIME_LIMIT, time_interval = Brocli::TIME_INTERVAL)
  begin
    average_time = client.ping(client.sanitizer(url), time_limit.to_f, time_interval.to_f)
    raise 'There is some error' unless average_time != nil
    puts "Average response time for #{url} is #{(average_time).round(Brocli::DEFAULT_ROUNDING)}s".green
  rescue Exception => e
    puts e.message.red
  end
end