lib/powerpack/string/strip_margin.rb in powerpack-0.0.2 vs lib/powerpack/string/strip_margin.rb in powerpack-0.0.3
- old
+ new
@@ -3,17 +3,17 @@
# The method strips the characters preceding a special margin character.
# Useful for HEREDOCs and other multi-line strings.
#
# @example
#
- # code = <<-END.strip_margin('|')
- # |def test
- # | some_method
- # | other_method
- # |end
- # END
+ # code = <<-END.strip_margin('|')
+ # |def test
+ # | some_method
+ # | other_method
+ # |end
+ # END
#
- # => "def\n some_method\n \nother_method\nend"
+ # #=> "def\n some_method\n \nother_method\nend"
def strip_margin(margin_character)
margin = '\\' + margin_character
gsub(/^\s+#{margin}/, '')
end
end