From 2650a0e766efabc520bfe168885ede0cc59dac37 Mon Sep 17 00:00:00 2001 From: Manoj Date: Thu, 4 Apr 2013 04:11:38 +0530 Subject: [PATCH] Avoid, method redefined warning for method indent --- lib/treetop/ruby_extensions/string.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/treetop/ruby_extensions/string.rb b/lib/treetop/ruby_extensions/string.rb index da34212..9ea5dbf 100644 --- a/lib/treetop/ruby_extensions/string.rb +++ b/lib/treetop/ruby_extensions/string.rb @@ -28,11 +28,13 @@ def tabto(n) end end - def indent(n) - if n >= 0 - gsub(/^/, ' ' * n) - else - gsub(/^ {0,#{-n}}/, "") + unless method_defined?(:indent) + def indent(n) + if n >= 0 + gsub(/^/, ' ' * n) + else + gsub(/^ {0,#{-n}}/, "") + end end end