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::SAFE_PCHAR, ActionController::Routing::Segment::UNSAFE_PCHAR
Instance Attribute Summary collapse
-
#raw ⇒ Object
(also: #raw?)
readonly
Returns the value of attribute raw.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Segment
Instance Method Summary collapse
- #build_pattern(pattern) ⇒ Object
-
#initialize(value = nil, options = {}) ⇒ StaticSegment
constructor
A new instance of StaticSegment.
- #interpolation_chunk ⇒ Object
- #number_of_captures ⇒ 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, options = {}) ⇒ StaticSegment
Returns a new instance of StaticSegment.
79 80 81 82 83 84 |
# File 'lib/action_controller/routing/segments.rb', line 79 def initialize(value = nil, = {}) super() @value = value @raw = [:raw] if .key?(:raw) @is_optional = [:optional] if .key?(:optional) end |
Instance Attribute Details
#raw ⇒ Object (readonly) Also known as: raw?
Returns the value of attribute raw.
76 77 78 |
# File 'lib/action_controller/routing/segments.rb', line 76 def raw @raw end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
76 77 78 |
# File 'lib/action_controller/routing/segments.rb', line 76 def value @value end |
Instance Method Details
#build_pattern(pattern) ⇒ Object
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/action_controller/routing/segments.rb', line 99 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
86 87 88 |
# File 'lib/action_controller/routing/segments.rb', line 86 def interpolation_chunk raw? ? value : super end |
#number_of_captures ⇒ Object
95 96 97 |
# File 'lib/action_controller/routing/segments.rb', line 95 def number_of_captures 0 end |
#regexp_chunk ⇒ Object
90 91 92 93 |
# File 'lib/action_controller/routing/segments.rb', line 90 def regexp_chunk chunk = Regexp.escape(value) optional? ? Regexp.optionalize(chunk) : chunk end |
#to_s ⇒ Object
110 111 112 |
# File 'lib/action_controller/routing/segments.rb', line 110 def to_s value end |