Class: Regexgen::Ast::Repetition
- Inherits:
-
Object
- Object
- Regexgen::Ast::Repetition
- Defined in:
- lib/regexgen/ast.rb
Overview
Represents a repetition (e.g. a* or a?)
Instance Attribute Summary collapse
-
#expr ⇒ Object
readonly
Returns the value of attribute expr.
-
#precedence ⇒ Object
readonly
Returns the value of attribute precedence.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(expr, type) ⇒ Repetition
constructor
A new instance of Repetition.
- #length ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(expr, type) ⇒ Repetition
Returns a new instance of Repetition.
128 129 130 131 132 |
# File 'lib/regexgen/ast.rb', line 128 def initialize(expr, type) @precedence = 3 @expr = expr @type = type end |
Instance Attribute Details
#expr ⇒ Object (readonly)
Returns the value of attribute expr.
126 127 128 |
# File 'lib/regexgen/ast.rb', line 126 def expr @expr end |
#precedence ⇒ Object (readonly)
Returns the value of attribute precedence.
126 127 128 |
# File 'lib/regexgen/ast.rb', line 126 def precedence @precedence end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
126 127 128 |
# File 'lib/regexgen/ast.rb', line 126 def type @type end |
Instance Method Details
#length ⇒ Object
134 135 136 |
# File 'lib/regexgen/ast.rb', line 134 def length @expr.length end |
#to_s ⇒ Object
138 139 140 |
# File 'lib/regexgen/ast.rb', line 138 def to_s Ast.parens(@expr, self) + @type end |