Class: Rack::Mount::GeneratableRegexp::DynamicSegment
- Inherits:
-
Object
- Object
- Rack::Mount::GeneratableRegexp::DynamicSegment
- Defined in:
- lib/rack/mount/generatable_regexp.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#requirement ⇒ Object
readonly
Returns the value of attribute requirement.
Instance Method Summary collapse
- #==(obj) ⇒ Object
- #=~(str) ⇒ Object
-
#initialize(name, requirement) ⇒ DynamicSegment
constructor
A new instance of DynamicSegment.
- #inspect ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(name, requirement) ⇒ DynamicSegment
Returns a new instance of DynamicSegment.
8 9 10 11 |
# File 'lib/rack/mount/generatable_regexp.rb', line 8 def initialize(name, requirement) @name, @requirement = name.to_sym, requirement freeze end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/rack/mount/generatable_regexp.rb', line 6 def name @name end |
#requirement ⇒ Object (readonly)
Returns the value of attribute requirement.
6 7 8 |
# File 'lib/rack/mount/generatable_regexp.rb', line 6 def requirement @requirement end |
Instance Method Details
#==(obj) ⇒ Object
13 14 15 |
# File 'lib/rack/mount/generatable_regexp.rb', line 13 def ==(obj) @name == obj.name && @requirement == obj.requirement end |
#=~(str) ⇒ Object
17 18 19 |
# File 'lib/rack/mount/generatable_regexp.rb', line 17 def =~(str) @requirement =~ str end |
#inspect ⇒ Object
25 26 27 |
# File 'lib/rack/mount/generatable_regexp.rb', line 25 def inspect "/(?<#{@name}>#{@requirement.source})/" end |
#to_hash ⇒ Object
21 22 23 |
# File 'lib/rack/mount/generatable_regexp.rb', line 21 def to_hash { @name => @requirement } end |