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.
609 610 611 612 |
# File 'lib/action_controller/routing.rb', line 609 def initialize(value = nil) super() self.value = value end |
Instance Attribute Details
#raw ⇒ Object Also known as: raw?
Returns the value of attribute raw.
606 607 608 |
# File 'lib/action_controller/routing.rb', line 606 def raw @raw end |
#value ⇒ Object
Returns the value of attribute value.
606 607 608 |
# File 'lib/action_controller/routing.rb', line 606 def value @value end |
Instance Method Details
#build_pattern(pattern) ⇒ Object
623 624 625 626 627 628 629 630 631 632 |
# File 'lib/action_controller/routing.rb', line 623 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
614 615 616 |
# File 'lib/action_controller/routing.rb', line 614 def interpolation_chunk raw? ? value : CGI.escape(value) end |
#regexp_chunk ⇒ Object
618 619 620 621 |
# File 'lib/action_controller/routing.rb', line 618 def regexp_chunk chunk = Regexp.escape value optional? ? Regexp.optionalize(chunk) : chunk end |
#to_s ⇒ Object
634 635 636 |
# File 'lib/action_controller/routing.rb', line 634 def to_s value end |