Class: UrlRegexp::Root
Instance Method Summary collapse
- #append(url) ⇒ Object
-
#initialize ⇒ Root
constructor
A new instance of Root.
- #to_regexp_s ⇒ Object
Methods inherited from Node
Constructor Details
Instance Method Details
#append(url) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/url_regexp/root.rb', line 14 def append(url) url = URI(url) unless url.is_a?(URI) @path.append(url.path) @scheme.append(url.scheme) @host.append(url.host) @query.append(url.query) end |
#to_regexp_s ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/url_regexp/root.rb', line 22 def to_regexp_s s = '^' + @scheme.to_regexp_s + @host.to_regexp_s + @path.to_regexp_s + @query.to_regexp_s + '(#|$)' s.sub('(\\?.*)?(#|$)', '([?#]|$)') end |