Class: Regexgen::Ast::Repetition

Inherits:
Object
  • Object
show all
Defined in:
lib/regexgen/ast.rb

Overview

Represents a repetition (e.g. ‘a*` or `a?`)

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#exprObject (readonly)

Returns the value of attribute expr.



126
127
128
# File 'lib/regexgen/ast.rb', line 126

def expr
  @expr
end

#precedenceObject (readonly)

Returns the value of attribute precedence.



126
127
128
# File 'lib/regexgen/ast.rb', line 126

def precedence
  @precedence
end

#typeObject (readonly)

Returns the value of attribute type.



126
127
128
# File 'lib/regexgen/ast.rb', line 126

def type
  @type
end

Instance Method Details

#lengthObject



134
135
136
# File 'lib/regexgen/ast.rb', line 134

def length
  @expr.length
end

#to_sObject



138
139
140
# File 'lib/regexgen/ast.rb', line 138

def to_s
  Ast.parens(@expr, self) + @type
end