Class: Reginald::Character
- Inherits:
-
String
- Object
- String
- Reginald::Character
- Defined in:
- lib/rack/mount/vendor/reginald/reginald/character.rb
Instance Attribute Summary collapse
-
#quantifier ⇒ Object
Returns the value of attribute quantifier.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #freeze ⇒ Object
- #include?(char) ⇒ Boolean
-
#initialize(char) ⇒ Character
constructor
A new instance of Character.
- #inspect ⇒ Object
- #literal? ⇒ Boolean
- #match(char) ⇒ Object
- #to_regexp ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(char) ⇒ Character
Returns a new instance of Character.
5 6 7 8 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 5 def initialize(char) raise ArgumentError if char.length != 1 super end |
Instance Attribute Details
#quantifier ⇒ Object
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
#==(other) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 34 def ==(other) case other when String other == to_s else eql?(other) end end |
#eql?(other) ⇒ Boolean
43 44 45 46 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 43 def eql?(other) other.is_a?(self.class) && super && self.quantifier == other.quantifier end |
#freeze ⇒ Object
48 49 50 51 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 48 def freeze quantifier.freeze super end |
#include?(char) ⇒ Boolean
30 31 32 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 30 def include?(char) to_str == char end |
#inspect ⇒ Object
22 23 24 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 22 def inspect to_s.inspect end |
#literal? ⇒ Boolean
10 11 12 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 10 def literal? quantifier.nil? end |
#match(char) ⇒ Object
26 27 28 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 26 def match(char) to_regexp.match(char) end |
#to_regexp ⇒ Object
18 19 20 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 18 def to_regexp Regexp.compile("\\A#{to_s}\\Z") end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/rack/mount/vendor/reginald/reginald/character.rb', line 14 def to_s "#{super}#{quantifier}" end |