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

:nodoc:



51
52
53
54
55
56
57
58
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 51

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

#capture?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 47

def capture?
  capture
end

#eql?(other) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


60
61
62
63
64
65
66
67
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 60

def eql?(other) #:nodoc:
  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

:nodoc:



69
70
71
72
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 69

def freeze #:nodoc:
  expression.freeze
  super
end

#ignorecase=(ignorecase) ⇒ Object



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

def ignorecase=(ignorecase)
  expression.ignorecase = ignorecase
end

#include?(char) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 43

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

#inspectObject

:nodoc:



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

def inspect #:nodoc:
  to_s.inspect
end

#literal?Boolean

Returns true if expression could be treated as a literal string.

A Group is literal if its expression is literal and it has no quantifier.

Returns:

  • (Boolean)


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

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

#match(char) ⇒ Object



39
40
41
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 39

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

#to_regexpObject



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

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

#to_s(parent = false) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 21

def to_s(parent = false)
  if expression.options == 0
    "(#{capture ? '' : '?:'}#{expression.to_s(parent)})#{quantifier}"
  elsif capture == false
    "#{expression.to_s}#{quantifier}"
  else
    "(#{expression.to_s})#{quantifier}"
  end
end