Class: Capture::Breadcrumb
- Inherits:
-
Object
- Object
- Capture::Breadcrumb
- Defined in:
- lib/rpeg/captures.rb
Overview
Used inside the VM when recording capture information.
Instance Attribute Summary collapse
-
#data ⇒ Object
From time to time we need to tweak each of these.
-
#kind ⇒ Object
From time to time we need to tweak each of these.
-
#size ⇒ Object
From time to time we need to tweak each of these.
-
#subject_index ⇒ Object
From time to time we need to tweak each of these.
Instance Method Summary collapse
- #close? ⇒ Boolean
-
#end_index ⇒ Object
The index of the end of the match, q.v.
-
#full? ⇒ Boolean
An “open” capture is a “full capture” if it has non-zero size.
-
#initialize(size, subject_index, data, kind) ⇒ Breadcrumb
constructor
q.v.
-
#to_s ⇒ Object
Dynamic because of the setters we sometimes use.
Constructor Details
#initialize(size, subject_index, data, kind) ⇒ Breadcrumb
q.v. LPEG’s Capture struct (lpcap.h)
We use size instead of siz, subject_index instead of s, and data instead of idx.
19 20 21 22 23 24 25 26 |
# File 'lib/rpeg/captures.rb', line 19 def initialize(size, subject_index, data, kind) raise "Bad Capture kind #{kind}" unless KINDS.include?(kind) @size = size @subject_index = subject_index @data = data @kind = kind end |
Instance Attribute Details
#data ⇒ Object
From time to time we need to tweak each of these
14 15 16 |
# File 'lib/rpeg/captures.rb', line 14 def data @data end |
#kind ⇒ Object
From time to time we need to tweak each of these
14 15 16 |
# File 'lib/rpeg/captures.rb', line 14 def kind @kind end |
#size ⇒ Object
From time to time we need to tweak each of these
14 15 16 |
# File 'lib/rpeg/captures.rb', line 14 def size @size end |
#subject_index ⇒ Object
From time to time we need to tweak each of these
14 15 16 |
# File 'lib/rpeg/captures.rb', line 14 def subject_index @subject_index end |
Instance Method Details
#close? ⇒ Boolean
33 34 35 |
# File 'lib/rpeg/captures.rb', line 33 def close? @kind == CLOSE end |
#end_index ⇒ Object
The index of the end of the match, q.v. LPEG’s closeaddr (lpcap.h)
38 39 40 |
# File 'lib/rpeg/captures.rb', line 38 def end_index @subject_index + size - 1 end |
#full? ⇒ Boolean
An “open” capture is a “full capture” if it has non-zero size. See isfullcap in lpcap.c
29 30 31 |
# File 'lib/rpeg/captures.rb', line 29 def full? @size.positive? end |
#to_s ⇒ Object
Dynamic because of the setters we sometimes use
43 44 45 |
# File 'lib/rpeg/captures.rb', line 43 def to_s "Breadcrumb size:#{size} sub_idx:#{subject_index} data:#{data.inspect} kind:#{kind}" end |