Class: ActionController::Routing::StaticSegment

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

Overview

:nodoc:

Direct Known Subclasses

DividerSegment

Constant Summary

Constants inherited from Segment

ActionController::Routing::Segment::RESERVED_PCHAR, ActionController::Routing::Segment::UNSAFE_PCHAR

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.



654
655
656
657
# File 'lib/action_controller/routing.rb', line 654

def initialize(value = nil)
  super()
  self.value = value
end

Instance Attribute Details

#rawObject Also known as: raw?

Returns the value of attribute raw.



651
652
653
# File 'lib/action_controller/routing.rb', line 651

def raw
  @raw
end

#valueObject

Returns the value of attribute value.



651
652
653
# File 'lib/action_controller/routing.rb', line 651

def value
  @value
end

Instance Method Details

#build_pattern(pattern) ⇒ Object



668
669
670
671
672
673
674
675
676
677
# File 'lib/action_controller/routing.rb', line 668

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



659
660
661
# File 'lib/action_controller/routing.rb', line 659

def interpolation_chunk
  raw? ? value : super
end

#regexp_chunkObject



663
664
665
666
# File 'lib/action_controller/routing.rb', line 663

def regexp_chunk
  chunk = Regexp.escape(value)
  optional? ? Regexp.optionalize(chunk) : chunk
end

#to_sObject



679
680
681
# File 'lib/action_controller/routing.rb', line 679

def to_s
  value
end