Class: TwitterCldr::Transforms::Cursor
- Inherits:
-
Object
- Object
- TwitterCldr::Transforms::Cursor
- Defined in:
- lib/twitter_cldr/transforms/cursor.rb
Instance Attribute Summary collapse
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #advance(amount = 1) ⇒ Object
- #eos? ⇒ Boolean
- #index_values ⇒ Object
-
#initialize(text) ⇒ Cursor
constructor
A new instance of Cursor.
- #reset_position ⇒ Object
- #set_text(new_text) ⇒ Object
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
#position ⇒ Object (readonly)
Returns the value of attribute position.
10 11 12 |
# File 'lib/twitter_cldr/transforms/cursor.rb', line 10 def position @position end |
#text ⇒ Object (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
29 30 31 |
# File 'lib/twitter_cldr/transforms/cursor.rb', line 29 def eos? position >= text.size end |
#index_values ⇒ Object
33 34 35 |
# File 'lib/twitter_cldr/transforms/cursor.rb', line 33 def index_values text[position].bytes end |
#reset_position ⇒ Object
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 |