Class: Regexp
Overview
:nodoc:
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.optionalize(pattern) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/action_controller/routing/routing_ext.rb', line 35 def optionalize(pattern) case unoptionalize(pattern) when /\A(.|\(.*\))\Z/ then "#{pattern}?" else "(?:#{pattern})?" end end |
.unoptionalize(pattern) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/action_controller/routing/routing_ext.rb', line 42 def unoptionalize(pattern) [/\A\(\?:(.*)\)\?\Z/, /\A(.|\(.*\))\?\Z/].each do |regexp| return $1 if regexp =~ pattern end return pattern end |
Instance Method Details
#multiline? ⇒ Boolean
30 31 32 |
# File 'lib/action_controller/routing/routing_ext.rb', line 30 def multiline? & MULTILINE == MULTILINE end |