Sha256: bf48796b649eb2f98fa9e2867f66459089e251d084b0171794e37e727e9984ed
Contents?: true
Size: 900 Bytes
Versions: 1
Compression:
Stored size: 900 Bytes
Contents
require_relative './node' module UrlRegexp class PathSet < Node include Enumerable extend Forwardable def_delegators :@set, :size, :hash, *Enumerable.public_instance_methods(false) def initialize(set = Set.new) @set = set end def append(path) set << path end def &(other) self.class.new(set & other.set) end def |(other) self.class.new(set & other.set) end def to_regexp_s s = if 5 < size "([^#?]*)" elsif 1 < size children_paths = map(&:paths).reduce { |s1, s2| s1 & s2 } if children_paths.size == 1 "(#{map(&:label).join("|")})/#{children_paths.to_regexp_s}" else "(#{map(&:to_regexp_s).join("|")})" end elsif 1 == size to_a.first.to_regexp_s else nil end end protected attr_reader :set end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
url_regexp-0.1.0 | lib/url_regexp/path_set.rb |