Class: Reginald::Group
- Inherits:
-
Struct
- Object
- Struct
- Reginald::Group
- Defined in:
- lib/rack/mount/vendor/reginald/reginald/group.rb
Instance Attribute Summary collapse
-
#capture ⇒ Object
Returns the value of attribute capture.
-
#expression ⇒ Object
Returns the value of attribute expression.
-
#index ⇒ Object
Returns the value of attribute index.
-
#name ⇒ Object
Returns the value of attribute name.
-
#quantifier ⇒ Object
Returns the value of attribute quantifier.
Instance Method Summary collapse
-
#==(other) ⇒ Object
:nodoc:.
- #capture? ⇒ Boolean
-
#eql?(other) ⇒ Boolean
:nodoc:.
-
#freeze ⇒ Object
:nodoc:.
- #ignorecase=(ignorecase) ⇒ Object
- #include?(char) ⇒ Boolean
-
#initialize(*args) ⇒ Group
constructor
A new instance of Group.
-
#inspect ⇒ Object
:nodoc:.
-
#literal? ⇒ Boolean
Returns true if expression could be treated as a literal string.
- #match(char) ⇒ Object
- #to_regexp ⇒ Object
- #to_s(parent = false) ⇒ Object
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
#capture ⇒ Object
Returns the value of attribute capture.
3 4 5 |
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 3 def capture @capture end |
#expression ⇒ Object
Returns the value of attribute expression
2 3 4 |
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 2 def expression @expression end |
#index ⇒ Object
Returns the value of attribute index.
3 4 5 |
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 3 def index @index end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 3 def name @name end |
#quantifier ⇒ Object
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
47 48 49 |
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 47 def capture? capture end |
#eql?(other) ⇒ Boolean
:nodoc:
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 |
#freeze ⇒ Object
: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
43 44 45 |
# File 'lib/rack/mount/vendor/reginald/reginald/group.rb', line 43 def include?(char) expression.include?(char) end |
#inspect ⇒ Object
: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.
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_regexp ⇒ Object
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. == 0 "(#{capture ? '' : '?:'}#{expression.to_s(parent)})#{quantifier}" elsif capture == false "#{expression.to_s}#{quantifier}" else "(#{expression.to_s})#{quantifier}" end end |