Class: Reginald::Character
- Defined in:
- lib/rack/mount/vendor/reginald/reginald/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:.
-
#freeze ⇒ Object
: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 ⇒ 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/reginald/reginald/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/reginald/reginald/character.rb', line 3 def quantifier @quantifier end |
Instance Method Details
#eql?(other) ⇒ Boolean
:nodoc:
45 46 47 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 45 def eql?(other) #:nodoc: super && quantifier.eql?(other.quantifier) end |
#freeze ⇒ Object
:nodoc:
49 50 51 52 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 49 def freeze #:nodoc: quantifier.freeze if quantifier super end |
#include?(char) ⇒ Boolean
37 38 39 40 41 42 43 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 37 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/reginald/reginald/character.rb', line 17 def literal? quantifier.nil? && !ignorecase end |
#match(char) ⇒ Object
33 34 35 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 33 def match(char) to_regexp.match(char) end |
#option_names ⇒ Object
10 11 12 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 10 def option_names %w( quantifier ) + super end |
#to_regexp ⇒ Object
29 30 31 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 29 def to_regexp Regexp.compile("\\A#{to_s(true)}\\Z", ignorecase) end |
#to_s(parent = false) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 21 def to_s(parent = false) if !parent && ignorecase "(?i-mx:#{value})#{quantifier}" else "#{value}#{quantifier}" end end |