Class: Steep::AST::Ignore::BufferScanner
- Defined in:
- lib/steep/ast/ignore.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#scanner ⇒ Object
readonly
Returns the value of attribute scanner.
Instance Method Summary collapse
- #charpos ⇒ Object
- #eos? ⇒ Boolean
-
#initialize(location) ⇒ BufferScanner
constructor
A new instance of BufferScanner.
- #offset ⇒ Object
- #scan(regexp) ⇒ Object
- #skip(regexp) ⇒ Object
Constructor Details
#initialize(location) ⇒ BufferScanner
Returns a new instance of BufferScanner.
7 8 9 10 11 |
# File 'lib/steep/ast/ignore.rb', line 7 def initialize(location) @location = location @scanner = StringScanner.new(location.source) end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
5 6 7 |
# File 'lib/steep/ast/ignore.rb', line 5 def location @location end |
#scanner ⇒ Object (readonly)
Returns the value of attribute scanner.
5 6 7 |
# File 'lib/steep/ast/ignore.rb', line 5 def scanner @scanner end |
Instance Method Details
#charpos ⇒ Object
17 18 19 |
# File 'lib/steep/ast/ignore.rb', line 17 def charpos scanner.charpos + offset end |
#eos? ⇒ Boolean
33 34 35 |
# File 'lib/steep/ast/ignore.rb', line 33 def eos? scanner.eos? end |
#offset ⇒ Object
13 14 15 |
# File 'lib/steep/ast/ignore.rb', line 13 def offset @location.start_pos end |
#scan(regexp) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/steep/ast/ignore.rb', line 21 def scan(regexp) if matched = scanner.scan(regexp) end_pos = charpos() begin_pos = end_pos - matched.size RBS::Location.new(location.buffer, begin_pos, end_pos) end end |
#skip(regexp) ⇒ Object
29 30 31 |
# File 'lib/steep/ast/ignore.rb', line 29 def skip(regexp) scanner.skip(regexp) end |