Module: MyCore::String
- Defined in:
- lib/my_core/string.rb
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.
5 6 7 8 9 10 11 12 |
# File 'lib/my_core/string.rb', line 5 def count_any(str) count = 0 self.gsub(str) {|s| count += 1 str } count end |