Sha256: 01ab59e4eb288df68741a1efe9ce58492631666bdb7c17912418b404d759ef41

Contents?: true

Size: 643 Bytes

Versions: 21

Compression:

Stored size: 643 Bytes

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

module TwitterCldr
  module Segmentation
    class Cursor
      attr_reader :text, :codepoints
      attr_accessor :position

      def initialize(text)
        @text = text
        @codepoints = text.codepoints
        reset
      end

      def advance(amount = 1)
        @position += amount
      end

      def reset
        @position = 0
      end

      def eos?
        position >= text.size
      end

      def codepoint(pos = @position)
        codepoints[pos]
      end

      def length
        text.length
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
twitter_cldr-6.11.3 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.11.2 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.11.1 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.11.0 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.10.0 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.9.0 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.8.0 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.7.0 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.6.2 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.6.1 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.6.0 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.5.0 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.4.0 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.3.0 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.2.0 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.1.0 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.0.2 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.0.1 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-6.0.0 lib/twitter_cldr/segmentation/cursor.rb
twitter_cldr-5.4.0 lib/twitter_cldr/segmentation/cursor.rb