How to use ARGV*,How do i implement command line argument in it

<<-doc
Modify the sum of times method for any number of time values passed to this method.
Eg: (“11:23:07”,“22:53:45”,“0:23:23”,“23:45:56”) -> “2 day & 10:26:11”
(“0:45:34”,“0:15:58”) -> 01:01:32 ; (“11:23:07”,“22:53:45”) -> 1 day & 10:16:52
doc

require ‘time’

def to_seconds(timestamp)
timestamp.hour * 3600 + timestamp.min * 60 + timestamp.sec
end

def sum_time(*time)

initialize the variables

total_seconds = 0
time.each do |time_item|
timestamp = Time.parse(time_item)
total_seconds += to_seconds(timestamp)
end
sum_time_string = “”
days = (total_seconds / (24 * 3600)).to_i
sum_time_string = “#{days} day & " if days > 0
sum_time_string += Time.at(total_seconds).utc.strftime(”%H:%M:%S")
end

puts sum_time(“11:23:07”,“22:53:45”,“0:23:23”,“23:45:56”)

You can use ARGV in the following way:

#!/usr/bin/ruby -w
if ARGV.include?('--help') || ARGV.include?('-h')
	puts(
		<<~EOF
			This program adds up the given times.
			You have to pass arguments in either
			hour:minute:second format or hour:minute format.

			For example:
				#{$PROGRAM_NAME} 1:1:1 2:2

			Expected Output:
				03:03:01
		EOF
	)
	exit! 0
end

require 'time'
Time.define_method(:to_seconds) { hour * 3600 + min * 60 + sec }

def sum_time(*time)
	total_seconds = time.flatten.map { |t| Time.parse(t).to_seconds }.sum

	days = total_seconds./(24 * 3600).to_i
	sum_time_string = days > 0 ? "#{days} day & " : ''
	sum_time_string << Time.at(total_seconds).utc.strftime('%H:%M:%S')
end

puts(sum_time(ARGV))

Here’s a screenshot for the outputs

Hope this help!