Class: UrlRegexp::PathSet
- Extended by:
- Forwardable
- Defined in:
- lib/url_regexp/path_set.rb
Instance Method Summary collapse
- #&(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #append(path) ⇒ Object
- #hash ⇒ Object
- #include?(path) ⇒ Boolean
-
#initialize(set = Set.new) ⇒ PathSet
constructor
A new instance of PathSet.
- #to_regexp_s ⇒ Object
- #|(other) ⇒ Object
Methods inherited from Node
Constructor Details
Instance Method Details
#&(other) ⇒ Object
37 38 39 |
# File 'lib/url_regexp/path_set.rb', line 37 def &(other) self.class.new(@set & other.set) end |
#==(other) ⇒ Object Also known as: eql?
26 27 28 29 |
# File 'lib/url_regexp/path_set.rb', line 26 def ==(other) self.class == other.class && @set.to_a == other.set.to_a end |
#append(path) ⇒ Object
22 23 24 |
# File 'lib/url_regexp/path_set.rb', line 22 def append(path) set << path end |
#hash ⇒ Object
33 34 35 |
# File 'lib/url_regexp/path_set.rb', line 33 def hash @set.hash end |
#include?(path) ⇒ Boolean
45 46 47 |
# File 'lib/url_regexp/path_set.rb', line 45 def include?(path) @set.include?(path) end |
#to_regexp_s ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/url_regexp/path_set.rb', line 49 def to_regexp_s if 5 < size '([^#?]*)' elsif 1 < size children_paths = map(&:paths).reduce { |a, e| a & e } if children_paths.size == 1 && all? { |p| !p.path_end } "(#{map(&:label).join('|')})/#{children_paths.to_regexp_s}" else "(#{map(&:to_regexp_s).join('|')})" end elsif 1 == size to_a.first.to_regexp_s end end |
#|(other) ⇒ Object
41 42 43 |
# File 'lib/url_regexp/path_set.rb', line 41 def |(other) self.class.new(@set & other.set) end |