Class: ActionController::Routing::StaticSegment

Inherits:
Segment show all
Defined in:
lib/action_controller/routing.rb

Overview

:nodoc:

Direct Known Subclasses

DividerSegment

Instance Attribute Summary collapse

Attributes inherited from Segment

#is_optional

Instance Method Summary collapse

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

#rawObject 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

#valueObject

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_chunkObject



605
606
607
# File 'lib/action_controller/routing.rb', line 605

def interpolation_chunk
  raw? ? value : CGI.escape(value)
end

#regexp_chunkObject



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_sObject



625
626
627
# File 'lib/action_controller/routing.rb', line 625

def to_s
  value
end