Class: String
Instance Method Summary collapse
-
#count_any(str) ⇒ Object
Counts # of times the given string is in the string.
Instance Method Details
#count_any(str) ⇒ Object
Counts # of times the given string is in the string. This is unlike String.count which only counts the given characters.
4 5 6 7 8 9 10 11 |
# File 'lib/core/string.rb', line 4 def count_any(str) count = 0 self.gsub(str) {|s| count += 1 str } count end |