Fig5 in Ruby