Class: UrlRegexp::Host
Instance Method Summary collapse
- #append(host) ⇒ Object
-
#initialize ⇒ Host
constructor
A new instance of Host.
- #to_regexp_s ⇒ Object
Methods inherited from Node
Constructor Details
#initialize ⇒ Host
Returns a new instance of Host.
3 4 5 |
# File 'lib/url_regexp/host.rb', line 3 def initialize @hosts = Set.new end |
Instance Method Details
#append(host) ⇒ Object
7 8 9 |
# File 'lib/url_regexp/host.rb', line 7 def append(host) @hosts << host end |
#to_regexp_s ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/url_regexp/host.rb', line 11 def to_regexp_s hosts = @hosts.map { |h| Regexp.quote(h.to_s) } if 1 < hosts.size "(#{hosts.join('|')})" else hosts[0] end end |