Class: Ferret::Utils::StringHelper::StringReader
- Inherits:
-
Object
- Object
- Ferret::Utils::StringHelper::StringReader
- Defined in:
- lib/ferret/utils/string_helper.rb
Overview
Methods for manipulating strings.
Instance Attribute Summary collapse
-
#length ⇒ Object
readonly
Returns the value of attribute length.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(str) ⇒ StringReader
constructor
A new instance of StringReader.
- #read(len = nil) ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize(str) ⇒ StringReader
Returns a new instance of StringReader.
8 9 10 11 12 |
# File 'lib/ferret/utils/string_helper.rb', line 8 def initialize(str) @str = str @pointer = 0 @length = @str.length end |
Instance Attribute Details
#length ⇒ Object (readonly)
Returns the value of attribute length.
6 7 8 |
# File 'lib/ferret/utils/string_helper.rb', line 6 def length @length end |
Instance Method Details
#close ⇒ Object
26 |
# File 'lib/ferret/utils/string_helper.rb', line 26 def close() str = nil end |
#read(len = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/ferret/utils/string_helper.rb', line 14 def read(len = nil) return @str if len.nil? return nil if @pointer > @length res = @str[@pointer, len] @pointer += len return res end |
#reset ⇒ Object
24 |
# File 'lib/ferret/utils/string_helper.rb', line 24 def reset() @pointer = 0 end |