Class: StringScanner
Overview
Simple substitution for strscan in Ruby for users that lack strscan.
Instance Attribute Summary collapse
-
#pointer ⇒ Object
Returns the value of attribute pointer.
Instance Method Summary collapse
- #check(regexp) ⇒ Object
-
#initialize(string) ⇒ StringScanner
constructor
A new instance of StringScanner.
- #rest ⇒ Object
- #rest? ⇒ Boolean
- #scan(regexp) ⇒ Object
- #string ⇒ Object
Constructor Details
#initialize(string) ⇒ StringScanner
Returns a new instance of StringScanner.
14 15 16 |
# File 'lib/rpdf2txt-rockit/stringscanner.rb', line 14 def initialize(string) @orig, @pointer = string, 0 end |
Instance Attribute Details
#pointer ⇒ Object
Returns the value of attribute pointer.
12 13 14 |
# File 'lib/rpdf2txt-rockit/stringscanner.rb', line 12 def pointer @pointer end |
Instance Method Details
#check(regexp) ⇒ Object
30 31 32 |
# File 'lib/rpdf2txt-rockit/stringscanner.rb', line 30 def check(regexp) apply_regexp(regexp, false) end |
#rest ⇒ Object
22 23 24 |
# File 'lib/rpdf2txt-rockit/stringscanner.rb', line 22 def rest @orig[pointer..-1] end |
#rest? ⇒ Boolean
26 27 28 |
# File 'lib/rpdf2txt-rockit/stringscanner.rb', line 26 def rest? rest.length > 0 end |
#scan(regexp) ⇒ Object
34 35 36 |
# File 'lib/rpdf2txt-rockit/stringscanner.rb', line 34 def scan(regexp) apply_regexp(regexp, true) end |
#string ⇒ Object
18 19 20 |
# File 'lib/rpdf2txt-rockit/stringscanner.rb', line 18 def string @orig end |