Sha256: 849cbb8c1b425bb543e55a9cafdacfd8dc0dcf07e440799c51ee15c6a145b607

Contents?: true

Size: 642 Bytes

Versions: 1

Compression:

Stored size: 642 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

1 entries across 1 versions & 1 rubygems

Version Path
twitter_cldr-5.2.0 lib/twitter_cldr/segmentation/cursor.rb