Class: Regin::Character
- Defined in:
- lib/rack/mount/vendor/regin/regin/character.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#quantifier ⇒ Object
readonly
Returns the value of attribute quantifier.
Attributes inherited from Atom
Instance Method Summary collapse
-
#eql?(other) ⇒ Boolean
:nodoc:.
- #include?(char) ⇒ Boolean
-
#initialize(value, options = {}) ⇒ Character
constructor
A new instance of Character.
-
#literal? ⇒ Boolean
Returns true if expression could be treated as a literal string.
- #match(char) ⇒ Object
- #option_names ⇒ Object
- #to_regexp(anchored = false) ⇒ Object
- #to_s(parent = false) ⇒ Object
Methods inherited from Atom
#==, #casefold?, #dup, #inspect
Constructor Details
#initialize(value, options = {}) ⇒ Character
Returns a new instance of Character.
5 6 7 8 |
# File 'lib/rack/mount/vendor/regin/regin/character.rb', line 5 def initialize(value, = {}) @quantifier = [:quantifier] super end |
Instance Attribute Details
#quantifier ⇒ Object (readonly)
Returns the value of attribute quantifier.
3 4 5 |
# File 'lib/rack/mount/vendor/regin/regin/character.rb', line 3 def quantifier @quantifier end |
Instance Method Details
#eql?(other) ⇒ Boolean
:nodoc:
47 48 49 |
# File 'lib/rack/mount/vendor/regin/regin/character.rb', line 47 def eql?(other) #:nodoc: super && quantifier.eql?(other.quantifier) end |
#include?(char) ⇒ Boolean
39 40 41 42 43 44 45 |
# File 'lib/rack/mount/vendor/regin/regin/character.rb', line 39 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.
17 18 19 |
# File 'lib/rack/mount/vendor/regin/regin/character.rb', line 17 def literal? quantifier.nil? && !ignorecase end |
#match(char) ⇒ Object
35 36 37 |
# File 'lib/rack/mount/vendor/regin/regin/character.rb', line 35 def match(char) to_regexp(true).match(char) end |
#option_names ⇒ Object
10 11 12 |
# File 'lib/rack/mount/vendor/regin/regin/character.rb', line 10 def option_names %w( quantifier ) + super end |
#to_regexp(anchored = false) ⇒ Object
29 30 31 32 33 |
# File 'lib/rack/mount/vendor/regin/regin/character.rb', line 29 def to_regexp(anchored = false) re = to_s(true) re = "\\A#{re}\\Z" if anchored Regexp.compile(re, ignorecase) end |
#to_s(parent = false) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/rack/mount/vendor/regin/regin/character.rb', line 21 def to_s(parent = false) if !parent && ignorecase "(?i-mx:#{value})#{quantifier}" else "#{value}#{quantifier}" end end |