Class: Regexp::Expression::Quantifier

Inherits:
Object
  • Object
show all
Defined in:
lib/regexp_parser/expression/quantifier.rb

Constant Summary collapse

MODES =
[:greedy, :possessive, :reluctant]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, text, min, max, mode) ⇒ Quantifier

Returns a new instance of Quantifier.



7
8
9
10
11
12
13
# File 'lib/regexp_parser/expression/quantifier.rb', line 7

def initialize(token, text, min, max, mode)
  @token = token
  @text  = text
  @mode  = mode
  @min   = min
  @max   = max
end

Instance Attribute Details

#maxObject (readonly)

Returns the value of attribute max.



5
6
7
# File 'lib/regexp_parser/expression/quantifier.rb', line 5

def max
  @max
end

#minObject (readonly)

Returns the value of attribute min.



5
6
7
# File 'lib/regexp_parser/expression/quantifier.rb', line 5

def min
  @min
end

#modeObject (readonly)

Returns the value of attribute mode.



5
6
7
# File 'lib/regexp_parser/expression/quantifier.rb', line 5

def mode
  @mode
end

#textObject (readonly)

Returns the value of attribute text.



5
6
7
# File 'lib/regexp_parser/expression/quantifier.rb', line 5

def text
  @text
end

#tokenObject (readonly)

Returns the value of attribute token.



5
6
7
# File 'lib/regexp_parser/expression/quantifier.rb', line 5

def token
  @token
end

Instance Method Details

#==(other) ⇒ Object Also known as: eq



44
45
46
47
48
49
50
# File 'lib/regexp_parser/expression/quantifier.rb', line 44

def ==(other)
  other.class == self.class &&
    other.token == token &&
    other.mode == mode &&
    other.min == min &&
    other.max == max
end

#initialize_copy(orig) ⇒ Object



15
16
17
18
# File 'lib/regexp_parser/expression/quantifier.rb', line 15

def initialize_copy(orig)
  @text = orig.text.dup
  super
end

#to_hObject



25
26
27
28
29
30
31
32
33
# File 'lib/regexp_parser/expression/quantifier.rb', line 25

def to_h
  {
    token: token,
    text:  text,
    mode:  mode,
    min:   min,
    max:   max,
  }
end

#to_sObject Also known as: to_str



20
21
22
# File 'lib/regexp_parser/expression/quantifier.rb', line 20

def to_s
  text.dup
end