Class: UrlRegexp::Scheme
Instance Method Summary collapse
- #append(scheme) ⇒ Object
-
#initialize(options = {}) ⇒ Scheme
constructor
A new instance of Scheme.
- #to_regexp_s ⇒ Object
Methods inherited from Node
Constructor Details
Instance Method Details
#append(scheme) ⇒ Object
10 11 12 |
# File 'lib/url_regexp/scheme.rb', line 10 def append(scheme) @schemes << scheme end |
#to_regexp_s ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/url_regexp/scheme.rb', line 14 def to_regexp_s schemes = @schemes.map { |s| Regexp.quote(s) } if schemes == %w(http https) 'https?://' elsif 1 < @schemes.size "(#{schemes.join('|')})://" elsif 1 == @schemes.size "#{schemes.to_a.first}://" else '' end end |