Class: TwitterCldr::Transforms::Cursor

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_cldr/transforms/cursor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Cursor

Returns a new instance of Cursor.



12
13
14
15
# File 'lib/twitter_cldr/transforms/cursor.rb', line 12

def initialize(text)
  set_text(text)
  reset_position
end

Instance Attribute Details

#positionObject (readonly)

Returns the value of attribute position.



10
11
12
# File 'lib/twitter_cldr/transforms/cursor.rb', line 10

def position
  @position
end

#textObject (readonly)

Returns the value of attribute text.



10
11
12
# File 'lib/twitter_cldr/transforms/cursor.rb', line 10

def text
  @text
end

Instance Method Details

#advance(amount = 1) ⇒ Object



17
18
19
# File 'lib/twitter_cldr/transforms/cursor.rb', line 17

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

#eos?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/twitter_cldr/transforms/cursor.rb', line 29

def eos?
  position >= text.size
end

#index_valuesObject



33
34
35
# File 'lib/twitter_cldr/transforms/cursor.rb', line 33

def index_values
  text[position].bytes
end

#reset_positionObject



25
26
27
# File 'lib/twitter_cldr/transforms/cursor.rb', line 25

def reset_position
  @position = 0
end

#set_text(new_text) ⇒ Object



21
22
23
# File 'lib/twitter_cldr/transforms/cursor.rb', line 21

def set_text(new_text)
  @text = new_text
end