lib/url_regexp/path.rb in url_regexp-0.1.1 vs lib/url_regexp/path.rb in url_regexp-0.1.2

- old
+ new

@@ -11,36 +11,40 @@ @parent = parent @paths = PathSet.new @path_end = false end - def path_end? - @path_end + def ==(other) + self.class == other.class && + @label == other.label && + @paths == other.paths && + @path_end == other.path_end end + alias eql? == + def hash - [@label, @paths.hash].hash + [@label, @paths, @path_end].hash end def append(path) if path == '' @paths.append(Path.new('', self)) + elsif @parent.nil? + _, label, rest = path.split('/', 3) else - if @parent.nil? - _, label, rest = path.split('/', 3) - else - label, rest = path.split('/', 2) + label, rest = path.split('/', 2) + end + if label + p = @paths.find { |pp| pp.label == label } + if p.nil? + p = Path.new(label, self) + @paths.append(p) end - if label - unless p = @paths.find { |_p| _p.label == label } - p = Path.new(label, self) - @paths.append(p) - end - if rest.nil? - p.path_end = true - else - p.append(rest) - end + if rest.nil? + p.path_end = true + else + p.append(rest) end end end def to_regexp_s