Class: RegularExpression::AST::Quantifier::Exact
- Inherits:
-
Object
- Object
- RegularExpression::AST::Quantifier::Exact
- Defined in:
- lib/regular_expression/ast.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Integer.
Instance Method Summary collapse
-
#initialize(value) ⇒ Exact
constructor
A new instance of Exact.
- #quantify(start, finish) ⇒ Object
- #to_dot(parent) ⇒ Object
Constructor Details
#initialize(value) ⇒ Exact
Returns a new instance of Exact.
298 299 300 |
# File 'lib/regular_expression/ast.rb', line 298 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Integer
296 297 298 |
# File 'lib/regular_expression/ast.rb', line 296 def value @value end |
Instance Method Details
#quantify(start, finish) ⇒ Object
306 307 308 309 310 311 312 |
# File 'lib/regular_expression/ast.rb', line 306 def quantify(start, finish) states = [start, *(value - 1).times.map { NFA::State.new }, finish] value.times do |index| yield states[index], states[index + 1] end end |
#to_dot(parent) ⇒ Object
302 303 304 |
# File 'lib/regular_expression/ast.rb', line 302 def to_dot(parent) parent.add_node(object_id, label: "{#{value}}", shape: "box") end |