control_flow/case_guard.rb

tests/_examples/control_flow/case_guard.rb in the metorex repository.

# Guard clauses in case/when statements
# Demonstrates using conditionals with case statements

temperature = 75
if temperature > 80
  puts "Hot!"
elsif temperature > 60
  puts "Warm"
elsif temperature > 40
  puts "Cool"
else
  puts "Cold!"
end

# Another example
value = 100
if value > 50
  puts "Large hundred"
else
  puts "Small hundred"
end

Output:

Warm
Large hundred