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
- #bracketed? ⇒ Boolean
-
#eql?(other) ⇒ Boolean
:nodoc:.
-
#freeze ⇒ Object
:nodoc:.
- #ignorecase=(ignorecase) ⇒ Object
- #include?(char) ⇒ Boolean
-
#literal? ⇒ Boolean
Returns true if expression could be treated as a literal string.
- #negated? ⇒ Boolean
- #to_s(parent = false) ⇒ Object
Methods inherited from Character
Methods inherited from Atom
#==, #casefold?, #initialize, #inspect
Constructor Details
This class inherits a constructor from Reginald::Atom
Instance Attribute Details
#negate ⇒ Object
Returns the value of attribute negate.
24 25 26 |
# File 'lib/rack/mount/vendor/reginald/reginald/character_class.rb', line 24 def negate @negate end |
Instance Method Details
#bracketed? ⇒ Boolean
37 38 39 |
# File 'lib/rack/mount/vendor/reginald/reginald/character_class.rb', line 37 def bracketed? value != '.' && value !~ /^\\[dDsSwW]$/ end |
#eql?(other) ⇒ Boolean
:nodoc:
58 59 60 |
# File 'lib/rack/mount/vendor/reginald/reginald/character_class.rb', line 58 def eql?(other) #:nodoc: super && negate == other.negate end |
#freeze ⇒ Object
:nodoc:
62 63 64 65 |
# File 'lib/rack/mount/vendor/reginald/reginald/character_class.rb', line 62 def freeze #:nodoc: negate.freeze super end |
#ignorecase=(ignorecase) ⇒ Object
18 19 20 21 22 |
# File 'lib/rack/mount/vendor/reginald/reginald/character_class.rb', line 18 def ignorecase=(ignorecase) if to_s !~ /\A\[:.*:\]\Z/ super end end |
#include?(char) ⇒ Boolean
53 54 55 56 |
# File 'lib/rack/mount/vendor/reginald/reginald/character_class.rb', line 53 def include?(char) re = quantifier ? to_s.sub(/#{Regexp.escape(quantifier)}$/, '') : to_s Regexp.compile("\\A#{re}\\Z").match(char) end |
#literal? ⇒ Boolean
Returns true if expression could be treated as a literal string.
A CharacterClass is never literal.
33 34 35 |
# File 'lib/rack/mount/vendor/reginald/reginald/character_class.rb', line 33 def literal? false end |
#negated? ⇒ Boolean
26 27 28 |
# File 'lib/rack/mount/vendor/reginald/reginald/character_class.rb', line 26 def negated? negate ? true : false end |
#to_s(parent = false) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rack/mount/vendor/reginald/reginald/character_class.rb', line 41 def to_s(parent = false) if bracketed? if !parent && ignorecase "(?i-mx:[#{negate && '^'}#{value}])#{quantifier}" else "[#{negate && '^'}#{value}]#{quantifier}" end else super end end |