Class: UrlRegexp::Host

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

Instance Method Summary collapse

Methods inherited from Node

#to_regexp

Constructor Details

#initialize(options = {}) ⇒ Host

Returns a new instance of Host.



3
4
5
6
# File 'lib/url_regexp/host.rb', line 3

def initialize(options = {})
  @hosts = Set.new
  @options = options
end

Instance Method Details

#append(host) ⇒ Object



8
9
10
# File 'lib/url_regexp/host.rb', line 8

def append(host)
  @hosts << host
end

#to_regexp_sObject



12
13
14
15
16
17
18
19
# File 'lib/url_regexp/host.rb', line 12

def to_regexp_s
  hosts = @hosts.map { |h| Regexp.quote(h.to_s) }
  if 1 < hosts.size
    "(#{hosts.join('|')})"
  else
    hosts[0]
  end
end