Sha256: 0403a7866246670c032c4240f4963b5749e70bd41c7be5677e9327067d9673af

Contents?: true

Size: 495 Bytes

Versions: 100

Compression:

Stored size: 495 Bytes

Contents

require 'strscan'

module ActiveSupport #:nodoc:
  module CoreExtensions #:nodoc:
    module String #:nodoc:
      # Custom string iterators
      module Iterators
        # Yields a single-character string for each character in the string.
        # When $KCODE = 'UTF8', multi-byte characters are yielded appropriately.
        def each_char
          scanner, char = StringScanner.new(self), /./mu
          loop { yield(scanner.scan(char) || break) }
        end
      end
    end
  end
end

Version data entries

100 entries across 100 versions & 8 rubygems

Version Path
backlog-0.0.0 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.0.1 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.0.2 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.0.5 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.0.4 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.1.1 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.1.0 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.1.2 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.2.0 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.2.1 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.3.0 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.3.3 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.3.1 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.3.2 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.3.4 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.3.5 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.3.6 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.3.8 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.3.7 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb
backlog-0.3.9 vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb