Skip to content

Commit

Permalink
Added 2 new generic helpers replace_stripper and substitute_stripper …
Browse files Browse the repository at this point in the history
…and bump version number
  • Loading branch information
nekogami committed Oct 8, 2017
1 parent 7a8d2b2 commit 9ca1efc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions lib/active_stripper/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,32 @@ def to_lower_stripper(val)
return val.downcase
end

#
# Execute String#tr on `val`, find `pattern` and replace with `replacements`
#
# @param [String] val String to clean up
# @param [String] pattern First parameters to method String#tr
# @param [String] replacements Second parameters to method String#tr
#
# @return [String] Cleaned up string
#
def replace_stripper(val, pattern, replacements)
return val.tr(pattern, replacements)
end

#
# Execute String#gsub on `val`, find `pattern` and replace with `replacement`
#
# @param [String] val String to clean up
# @param [String] pattern First parameters to method String#gsub
# @param [String] replacement Second parameters to method String#gsub
#
# @return [String] Cleaned up string
#
def substitute_stripper(val, pattern, replacement)
return val.gsub(pattern, replacement)
end

#
# Set value to nil if val is an empty string
#
Expand Down
2 changes: 1 addition & 1 deletion lib/active_stripper/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#coding: utf-8

module ActiveStripper
VERSION = "1.0.1"
VERSION = "1.1.0"
end

0 comments on commit 9ca1efc

Please sign in to comment.