I took the liberty of converting the for loop to an iterator as ruby has no for loop we speak of :)
And here is the code:
require 'time'
USERS = %w(Marvin Ray John Rick Mayte Hannah Jessica Laura)
def current_daytime
return :night if Time.now < Time.parse("05:00 am")
return :morning if Time.now < Time.parse("10:00 am")
return :day if Time.now < Time.parse("15:00 am")
return :afternoon if Time.now < Time.parse("20:00 am")
:evening
end
def pretty_daytime
current_daytime.to_s.capitalize
end
def greet(name)
puts "Good #{pretty_daytime} to you, #{name}!"
end
def hello_world
puts "Hey, what is your name?"
name = gets.strip
puts "Hello World, it is currently #{Time.now.to_s} for me..."
puts "With me are #{USERS.join(', ')} and #{name}!"
USERS.push name
USERS.each do |user|
greet user
end
puts "What a nice #{pretty_daytime} it is with all my friends!"
end
hello_world
runnable at https://repl.it/LPGy
Looking great!