Class: RegularExpression::AST::Quantifier::AtLeast
- Inherits:
-
Object
- Object
- RegularExpression::AST::Quantifier::AtLeast
- Defined in:
- lib/regular_expression/ast.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Integer.
Instance Method Summary collapse
-
#initialize(value) ⇒ AtLeast
constructor
A new instance of AtLeast.
- #quantify(start, finish) ⇒ Object
- #to_dot(parent) ⇒ Object
Constructor Details
#initialize(value) ⇒ AtLeast
Returns a new instance of AtLeast.
318 319 320 |
# File 'lib/regular_expression/ast.rb', line 318 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Integer
316 317 318 |
# File 'lib/regular_expression/ast.rb', line 316 def value @value end |
Instance Method Details
#quantify(start, finish) ⇒ Object
326 327 328 329 330 331 332 333 334 |
# File 'lib/regular_expression/ast.rb', line 326 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 states[-1].add_transition(NFA::Transition::Epsilon.new(states[-2])) end |
#to_dot(parent) ⇒ Object
322 323 324 |
# File 'lib/regular_expression/ast.rb', line 322 def to_dot(parent) parent.add_node(object_id, label: "{#{value},}", shape: "box") end |