Class: ActionController::Routing::StaticSegment
- Defined in:
- lib/action_controller/routing.rb
Overview
:nodoc:
Direct Known Subclasses
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.
600 601 602 603 |
# File 'lib/action_controller/routing.rb', line 600 def initialize(value = nil) super() self.value = value end |
Instance Attribute Details
#raw ⇒ Object Also known as: raw?
Returns the value of attribute raw.
597 598 599 |
# File 'lib/action_controller/routing.rb', line 597 def raw @raw end |
#value ⇒ Object
Returns the value of attribute value.
597 598 599 |
# File 'lib/action_controller/routing.rb', line 597 def value @value end |
Instance Method Details
#build_pattern(pattern) ⇒ Object
614 615 616 617 618 619 620 621 622 623 |
# File 'lib/action_controller/routing.rb', line 614 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
605 606 607 |
# File 'lib/action_controller/routing.rb', line 605 def interpolation_chunk raw? ? value : CGI.escape(value) end |
#regexp_chunk ⇒ Object
609 610 611 612 |
# File 'lib/action_controller/routing.rb', line 609 def regexp_chunk chunk = Regexp.escape value optional? ? Regexp.optionalize(chunk) : chunk end |
#to_s ⇒ Object
625 626 627 |
# File 'lib/action_controller/routing.rb', line 625 def to_s value end |