class TwitterCldr::Segmentation::Cursor

Attributes

codepoints[R]
position[RW]
text[R]

Public Class Methods

new(text) click to toggle source
# File lib/twitter_cldr/segmentation/cursor.rb, line 12
def initialize(text)
  @text = text
  @codepoints = text.codepoints
  reset
end

Public Instance Methods

advance(amount = 1) click to toggle source
# File lib/twitter_cldr/segmentation/cursor.rb, line 18
def advance(amount = 1)
  @position += amount
end
codepoint(pos = @position) click to toggle source
# File lib/twitter_cldr/segmentation/cursor.rb, line 30
def codepoint(pos = @position)
  codepoints[pos]
end
eos?() click to toggle source
# File lib/twitter_cldr/segmentation/cursor.rb, line 26
def eos?
  position >= text.size
end
length() click to toggle source
# File lib/twitter_cldr/segmentation/cursor.rb, line 34
def length
  text.length
end
reset() click to toggle source
# File lib/twitter_cldr/segmentation/cursor.rb, line 22
def reset
  @position = 0
end