From the documentation for String#count I understand the first example, but I do not understand the rest of the examples:
a = \"hello world\"
a.count \"lo\"
If you pass more than 1 parameter to count, it will use the intersection of those strings and will use that as the search target:
a = "hello world"
a.count "lo" #=> finds 5 instances of either "l" or "o"
a.count "lo", "o" #=> the intersection of "lo" and "o" is "o", so it finds 2 instances
a.count "hello", "^l" #=> the intersection of "hello" and "everything that is not "l" finds 4 instances of either "h", "e" or "o"
a.count "ej-m" #=> finds 4 instances of "e", "j", "k", "l" or "m" (the "j-m" part)