Class: Reginald::Character
- Defined in:
- lib/rack/mount/vendor/reginald/reginald/character.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#quantifier ⇒ Object
Returns the value of attribute quantifier.
Attributes inherited from Atom
Instance Method Summary collapse
-
#eql?(other) ⇒ Boolean
:nodoc:.
-
#freeze ⇒ Object
:nodoc:.
- #include?(char) ⇒ Boolean
-
#literal? ⇒ Boolean
Returns true if expression could be treated as a literal string.
- #match(char) ⇒ Object
- #to_regexp ⇒ Object
- #to_s(parent = false) ⇒ Object
Methods inherited from Atom
#==, #casefold?, #initialize, #inspect
Constructor Details
This class inherits a constructor from Reginald::Atom
Instance Attribute Details
#quantifier ⇒ Object
Returns the value of attribute quantifier.
3 4 5 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 3 def quantifier @quantifier end |
Instance Method Details
#eql?(other) ⇒ Boolean
:nodoc:
36 37 38 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 36 def eql?(other) #:nodoc: super && quantifier.eql?(other.quantifier) end |
#freeze ⇒ Object
:nodoc:
40 41 42 43 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 40 def freeze #:nodoc: quantifier.freeze super end |
#include?(char) ⇒ Boolean
28 29 30 31 32 33 34 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 28 def include?(char) if ignorecase value.downcase == char.downcase else value == char end end |
#literal? ⇒ Boolean
Returns true if expression could be treated as a literal string.
A Character is literal is there is no quantifier attached to it.
8 9 10 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 8 def literal? quantifier.nil? && !ignorecase end |
#match(char) ⇒ Object
24 25 26 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 24 def match(char) to_regexp.match(char) end |
#to_regexp ⇒ Object
20 21 22 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 20 def to_regexp Regexp.compile("\\A#{to_s(true)}\\Z", ignorecase) end |
#to_s(parent = false) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 12 def to_s(parent = false) if !parent && ignorecase "(?i-mx:#{value})#{quantifier}" else "#{value}#{quantifier}" end end |