Class: Reginald::CharacterClass
- Defined in:
- lib/rack/mount/vendor/reginald/reginald/character_class.rb
Constant Summary collapse
- ALNUM =
new(':alnum:').freeze
- ALPHA =
new(':alpha:').freeze
- ASCII =
new(':ascii:').freeze
- BLANK =
new(':blank:').freeze
- CNTRL =
new(':cntrl:').freeze
- DIGIT =
new(':digit:').freeze
- GRAPH =
new(':graph:').freeze
- LOWER =
new(':lower:').freeze
- PRINT =
new(':print:').freeze
- PUNCT =
new(':punct:').freeze
- SPACE =
new(':space:').freeze
- UPPER =
new(':upper:').freeze
- WORD =
new(':word:').freeze
- XDIGIT =
new(':xdigit:').freeze
Instance Attribute Summary collapse
-
#negate ⇒ Object
Returns the value of attribute negate.
Attributes inherited from Character
Attributes inherited from Atom
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #freeze ⇒ Object
- #include?(char) ⇒ Boolean
- #literal? ⇒ Boolean
- #negated? ⇒ Boolean
- #to_s ⇒ Object
Methods inherited from Character
Methods inherited from Atom
Instance Attribute Details
#negate ⇒ Object
Returns the value of attribute negate.
18 19 20 |
# File 'lib/rack/mount/vendor/reginald/reginald/character_class.rb', line 18 def negate @negate end |
Instance Method Details
#eql?(other) ⇒ Boolean
41 42 43 44 45 |
# File 'lib/rack/mount/vendor/reginald/reginald/character_class.rb', line 41 def eql?(other) other.is_a?(self.class) && negate == other.negate && super end |
#freeze ⇒ Object
47 48 49 50 |
# File 'lib/rack/mount/vendor/reginald/reginald/character_class.rb', line 47 def freeze negate.freeze super end |
#include?(char) ⇒ Boolean
36 37 38 39 |
# File 'lib/rack/mount/vendor/reginald/reginald/character_class.rb', line 36 def include?(char) re = quantifier ? to_s.sub(/#{Regexp.escape(quantifier)}$/, '') : to_s Regexp.compile("\\A#{re}\\Z").match(char) end |
#literal? ⇒ Boolean
24 25 26 |
# File 'lib/rack/mount/vendor/reginald/reginald/character_class.rb', line 24 def literal? false end |
#negated? ⇒ Boolean
20 21 22 |
# File 'lib/rack/mount/vendor/reginald/reginald/character_class.rb', line 20 def negated? negate ? true : false end |
#to_s ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/rack/mount/vendor/reginald/reginald/character_class.rb', line 28 def to_s if value == '.' || value =~ /^\\[dDsSwW]$/ super else "[#{negate && '^'}#{value}]#{quantifier}" end end |