Class: Reginald::Group

Inherits:
Struct
  • Object
show all
Defined in:
lib/rack/mount/vendor/reginald/reginald/group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Group

Returns a new instance of Group.



5
6
7
8
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 5

def initialize(*args)
  @capture = true
  super
end

Instance Attribute Details

#captureObject

Returns the value of attribute capture.



3
4
5
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 3

def capture
  @capture
end

#expressionObject

Returns the value of attribute expression

Returns:

  • (Object)

    the current value of expression



2
3
4
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 2

def expression
  @expression
end

#indexObject

Returns the value of attribute index.



3
4
5
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 3

def index
  @index
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 3

def name
  @name
end

#quantifierObject

Returns the value of attribute quantifier.



3
4
5
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 3

def quantifier
  @quantifier
end

Instance Method Details

#==(other) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 38

def ==(other)
  case other
  when String
    other == to_s
  else
    eql?(other)
  end
end

#capture?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 34

def capture?
  capture
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
50
51
52
53
54
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 47

def eql?(other)
  other.is_a?(self.class) &&
    self.expression == other.expression &&
    self.quantifier == other.quantifier &&
    self.capture == other.capture &&
    self.index == other.index &&
    self.name == other.name
end

#freezeObject



56
57
58
59
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 56

def freeze
  expression.freeze
  super
end

#include?(char) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 30

def include?(char)
  expression.include?(char)
end

#inspectObject



22
23
24
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 22

def inspect
  to_s.inspect
end

#literal?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 10

def literal?
  quantifier.nil? && expression.literal?
end

#match(char) ⇒ Object



26
27
28
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 26

def match(char)
  to_regexp.match(char)
end

#to_regexpObject



18
19
20
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 18

def to_regexp
  Regexp.compile("\\A#{to_s}\\Z")
end

#to_sObject



14
15
16
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 14

def to_s
  "(#{capture ? '' : '?:'}#{expression.to_s})#{quantifier}"
end