Class: ActionController::Routing::StaticSegment
- Defined in:
- lib/action_controller/routing/segments.rb
Overview
:nodoc:
Direct Known Subclasses
Constant Summary
Constants inherited from Segment
ActionController::Routing::Segment::RESERVED_PCHAR, ActionController::Routing::Segment::UNSAFE_PCHAR
Instance Attribute Summary collapse
-
#raw ⇒ Object
(also: #raw?)
Returns the value of attribute raw.
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from Segment
Instance Method Summary collapse
- #build_pattern(pattern) ⇒ Object
-
#initialize(value = nil) ⇒ StaticSegment
constructor
A new instance of StaticSegment.
- #interpolation_chunk ⇒ Object
- #regexp_chunk ⇒ Object
- #to_s ⇒ Object
Methods inherited from Segment
#all_optionals_available_condition, #continue_string_structure, #extraction_code, #interpolation_statement, #match_extraction, #optionality_implied?, #string_structure
Constructor Details
#initialize(value = nil) ⇒ StaticSegment
Returns a new instance of StaticSegment.
69 70 71 72 |
# File 'lib/action_controller/routing/segments.rb', line 69 def initialize(value = nil) super() self.value = value end |
Instance Attribute Details
#raw ⇒ Object Also known as: raw?
Returns the value of attribute raw.
66 67 68 |
# File 'lib/action_controller/routing/segments.rb', line 66 def raw @raw end |
#value ⇒ Object
Returns the value of attribute value.
66 67 68 |
# File 'lib/action_controller/routing/segments.rb', line 66 def value @value end |
Instance Method Details
#build_pattern(pattern) ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/action_controller/routing/segments.rb', line 83 def build_pattern(pattern) escaped = Regexp.escape(value) if optional? && ! pattern.empty? "(?:#{Regexp.optionalize escaped}\\Z|#{escaped}#{Regexp.unoptionalize pattern})" elsif optional? Regexp.optionalize escaped else escaped + pattern end end |
#interpolation_chunk ⇒ Object
74 75 76 |
# File 'lib/action_controller/routing/segments.rb', line 74 def interpolation_chunk raw? ? value : super end |
#regexp_chunk ⇒ Object
78 79 80 81 |
# File 'lib/action_controller/routing/segments.rb', line 78 def regexp_chunk chunk = Regexp.escape(value) optional? ? Regexp.optionalize(chunk) : chunk end |
#to_s ⇒ Object
94 95 96 |
# File 'lib/action_controller/routing/segments.rb', line 94 def to_s value end |