Sha256: fc3d0f3d10164412c1e94c1fb0a1c04fca5824e16a1189f158557d0da961aeef

Contents?: true

Size: 600 Bytes

Versions: 38

Compression:

Stored size: 600 Bytes

Contents

require 'strscan'

module ActiveSupport #:nodoc:
  module CoreExtensions #:nodoc:
    module String #:nodoc:
      # Custom string iterators
      module Iterators
        def self.append_features(base)
          super unless '1.9'.respond_to?(:each_char)
        end

        # 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

38 entries across 37 versions & 13 rubygems

Version Path
3mix-castronaut-0.5.0.2 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
masover-castronaut-0.4.4.4 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
masover-castronaut-0.4.4.5 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
masover-castronaut-0.5.0.1 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
p8-castronaut-0.6.1.1 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
relevance-castronaut-0.4.1 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
relevance-castronaut-0.4.2 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
relevance-castronaut-0.4.3 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
relevance-castronaut-0.4.4 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
relevance-castronaut-0.4.5 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
relevance-castronaut-0.4.6 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
relevance-castronaut-0.5.0 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
relevance-castronaut-0.5.1 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
relevance-castronaut-0.5.2 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
relevance-castronaut-0.5.3 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
relevance-castronaut-0.5.4 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
relevance-castronaut-0.6.0 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
relevance-castronaut-0.6.1 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
relevance-castronaut-0.7.4 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb
relevance-castronaut-0.7.5 vendor/activesupport/lib/active_support/core_ext/string/iterators.rb