aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2014-11-06 17:31:16 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2014-11-06 17:31:16 +0530
commit60c45b0d0aa89b3737e0706890d9552c2c98e38e (patch)
tree8d68bb67650e81cb404eb33589df143e7e665f41 /activesupport/lib/active_support
parent5dd3c3b2a0269eaa7cddfaed3136dc53dbf333e1 (diff)
parent54a9653a04f43917eab0b323ef4ba5b1fc6c05f4 (diff)
downloadrails-60c45b0d0aa89b3737e0706890d9552c2c98e38e.tar.gz
rails-60c45b0d0aa89b3737e0706890d9552c2c98e38e.tar.bz2
rails-60c45b0d0aa89b3737e0706890d9552c2c98e38e.zip
Merge pull request #17526 from rishijain/update_docs_6
Update docs 6
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/string/filters.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/filters.rb b/activesupport/lib/active_support/core_ext/string/filters.rb
index 499b9b26bc..096292dc58 100644
--- a/activesupport/lib/active_support/core_ext/string/filters.rb
+++ b/activesupport/lib/active_support/core_ext/string/filters.rb
@@ -13,6 +13,9 @@ class String
end
# Performs a destructive squish. See String#squish.
+ # str = " foo bar \n \t boo"
+ # str.squish! # => "foo bar boo"
+ # str # => "foo bar boo"
def squish!
gsub!(/\A[[:space:]]+/, '')
gsub!(/[[:space:]]+\z/, '')
@@ -21,11 +24,17 @@ class String
end
# Returns a new string with all occurrences of the patterns removed.
+ # str = "foo bar test"
+ # str.remove(" test") # => "foo bar"
+ # str # => "foo bar test"
def remove(*patterns)
dup.remove!(*patterns)
end
# Alters the string by removing all occurrences of the patterns.
+ # str = "foo bar test"
+ # str.remove!(" test") # => "foo bar"
+ # str # => "foo bar"
def remove!(*patterns)
patterns.each do |pattern|
gsub! pattern, ""