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