From 1b24341478fd4f6777d3184c7df3aa23ba2b5cb8 Mon Sep 17 00:00:00 2001 From: Keala Lusk Date: Fri, 6 Nov 2015 18:51:25 -0800 Subject: [PATCH] problem 1.4 --- ruby/lib/data-structures/chapter-1/1_4.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 ruby/lib/data-structures/chapter-1/1_4.rb diff --git a/ruby/lib/data-structures/chapter-1/1_4.rb b/ruby/lib/data-structures/chapter-1/1_4.rb new file mode 100644 index 00000000..bfc3d7c9 --- /dev/null +++ b/ruby/lib/data-structures/chapter-1/1_4.rb @@ -0,0 +1,15 @@ +module Strings + extend self + def replace_with_percent (str) + new_string = "" + str.each_char do |c| + if c == " " + c.replace "%20" + new_string = new_string + c + else + new_string = new_string + c + end + end + return new_string + end +end