Module: ActiveSupport::CoreExtensions::String::Iterators
- Included in:
- String
- Defined in:
- lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/iterators.rb
Overview
Custom string iterators
Class Method Summary collapse
Instance Method Summary collapse
-
#each_char ⇒ Object
Yields a single-character string for each character in the string.
Class Method Details
.append_features(base) ⇒ Object
8 9 10 |
# File 'lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/iterators.rb', line 8 def self.append_features(base) super unless '1.9'.respond_to?(:each_char) end |
Instance Method Details
#each_char ⇒ Object
Yields a single-character string for each character in the string. When $KCODE = ‘UTF8’, multi-byte characters are yielded appropriately.
14 15 16 17 |
# File 'lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/iterators.rb', line 14 def each_char scanner, char = StringScanner.new(self), /./mu loop { yield(scanner.scan(char) || break) } end |