mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 21:14:23 +02:00

(https://github.com/ruby/strscan/pull/126)
Split off from https://github.com/ruby/ruby/pull/12322
9bee37e0f5
30 lines
649 B
Markdown
30 lines
649 B
Markdown
call-seq:
|
|
terminate -> self
|
|
|
|
Sets the scanner to end-of-string;
|
|
returns +self+:
|
|
|
|
- Sets both [positions][11] to end-of-stream.
|
|
- Clears [match values][9].
|
|
|
|
```rb
|
|
scanner = StringScanner.new(HIRAGANA_TEXT)
|
|
scanner.string # => "こんにちは"
|
|
scanner.scan_until(/に/)
|
|
put_situation(scanner)
|
|
# Situation:
|
|
# pos: 9
|
|
# charpos: 3
|
|
# rest: "ちは"
|
|
# rest_size: 6
|
|
match_values_cleared?(scanner) # => false
|
|
|
|
scanner.terminate # => #<StringScanner fin>
|
|
put_situation(scanner)
|
|
# Situation:
|
|
# pos: 15
|
|
# charpos: 5
|
|
# rest: ""
|
|
# rest_size: 0
|
|
match_values_cleared?(scanner) # => true
|
|
```
|