Class: Regin::CharacterClass
- Defined in:
- lib/rack/mount/vendor/regin/regin/character_class.rb
Instance Attribute Summary collapse
-
#negate ⇒ Object
readonly
Returns the value of attribute negate.
Attributes inherited from Character
Attributes inherited from Atom
Instance Method Summary collapse
- #bracketed? ⇒ Boolean
-
#eql?(other) ⇒ Boolean
:nodoc:.
- #include?(char) ⇒ Boolean
-
#initialize(value, options = {}) ⇒ CharacterClass
constructor
A new instance of CharacterClass.
-
#literal? ⇒ Boolean
Returns true if expression could be treated as a literal string.
- #negated? ⇒ Boolean
- #option_names ⇒ Object
- #to_s(parent = false) ⇒ Object
Methods inherited from Character
Methods inherited from Atom
#==, #casefold?, #dup, #inspect
Constructor Details
#initialize(value, options = {}) ⇒ CharacterClass
Returns a new instance of CharacterClass.
3 4 5 6 |
# File 'lib/rack/mount/vendor/regin/regin/character_class.rb', line 3 def initialize(value, = {}) @negate = [:negate] super end |
Instance Attribute Details
#negate ⇒ Object (readonly)
Returns the value of attribute negate.
12 13 14 |
# File 'lib/rack/mount/vendor/regin/regin/character_class.rb', line 12 def negate @negate end |
Instance Method Details
#bracketed? ⇒ Boolean
25 26 27 |
# File 'lib/rack/mount/vendor/regin/regin/character_class.rb', line 25 def bracketed? value != '.' && value !~ /^\\[dDsSwW]$/ end |
#eql?(other) ⇒ Boolean
:nodoc:
46 47 48 |
# File 'lib/rack/mount/vendor/regin/regin/character_class.rb', line 46 def eql?(other) #:nodoc: super && negate == other.negate end |
#include?(char) ⇒ Boolean
41 42 43 44 |
# File 'lib/rack/mount/vendor/regin/regin/character_class.rb', line 41 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.
21 22 23 |
# File 'lib/rack/mount/vendor/regin/regin/character_class.rb', line 21 def literal? false end |
#negated? ⇒ Boolean
14 15 16 |
# File 'lib/rack/mount/vendor/regin/regin/character_class.rb', line 14 def negated? negate ? true : false end |
#option_names ⇒ Object
8 9 10 |
# File 'lib/rack/mount/vendor/regin/regin/character_class.rb', line 8 def option_names %w( negate ) + super end |
#to_s(parent = false) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rack/mount/vendor/regin/regin/character_class.rb', line 29 def to_s(parent = false) if bracketed? if !parent && ignorecase "(?i-mx:[#{negate && '^'}#{value}])#{quantifier}" else "[#{negate && '^'}#{value}]#{quantifier}" end else super end end |