Class: TreeSitter::QueryCaptures
- Inherits:
-
Object
- Object
- TreeSitter::QueryCaptures
- Includes:
- Enumerable
- Defined in:
- lib/tree_sitter/query_captures.rb
Overview
A sequence of QueryCapture associated with a given QueryCursor.
Instance Method Summary collapse
-
#each {|match, capture_index| ... } ⇒ Object
Iterator over captures.
-
#initialize(cursor, query, src) ⇒ QueryCaptures
constructor
A new instance of QueryCaptures.
Constructor Details
#initialize(cursor, query, src) ⇒ QueryCaptures
Returns a new instance of QueryCaptures.
8 9 10 11 12 |
# File 'lib/tree_sitter/query_captures.rb', line 8 def initialize(cursor, query, src) @cursor = cursor @query = query @src = src end |
Instance Method Details
#each {|match, capture_index| ... } ⇒ Object
Iterator over captures.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/tree_sitter/query_captures.rb', line 18 def each(&_block) return enum_for __method__ if !block_given? while (capture_index, match = @cursor.next_capture) next if !match.is_a?(TreeSitter::QueryMatch) if match.satisfies_text_predicate?(@query, @src) yield [match, capture_index] end end end |