Fig4 in Ruby