Class: UrlRegexp::Root

Inherits:
Node
  • Object
show all
Defined in:
lib/url_regexp/root.rb

Instance Method Summary collapse

Methods inherited from Node

#eql?, #to_regexp

Constructor Details

#initializeRoot

Returns a new instance of Root.



7
8
9
10
11
12
# File 'lib/url_regexp/root.rb', line 7

def initialize
  @scheme = Scheme.new
  @host = Host.new
  @path = Path.new
  @query = Query.new
end

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_sObject



22
23
24
# File 'lib/url_regexp/root.rb', line 22

def to_regexp_s
  "^#{@scheme.to_regexp_s}#{@host.to_regexp_s}#{@path.to_regexp_s}#{@query.to_regexp_s}(#|$)"
end