PHP 8.2.31
Preview: ypath.rb Size: 1.35 KB
/proc/thread-self/root/opt/alt/ruby19/lib64/ruby/1.9.1/syck/ypath.rb

#
# YAML::YPath
#

warn "#{caller[0]}: YAML::YPath is deprecated" if $VERBOSE

module Syck

    class YPath
        attr_accessor :segments, :predicates, :flags
        def initialize( str )
            @segments = []
            @predicates = []
            @flags = nil
            while str =~ /^\/?(\/|[^\/\[]+)(?:\[([^\]]+)\])?/
                @segments.push $1
                @predicates.push $2
                str = $'
            end
            unless str.to_s.empty?
                @segments += str.split( "/" )
            end
            if @segments.length == 0
                @segments.push "."
            end
        end
        def self.each_path( str )
            #
            # Find choices
            #
            paths = []
            str = "(#{ str })"
            while str.sub!( /\(([^()]+)\)/, "\n#{ paths.length }\n" )
                paths.push $1.split( '|' )
            end

            #
            # Construct all possible paths
            #
            all = [ str ]
            ( paths.length - 1 ).downto( 0 ) do |i|
                all = all.collect do |a|
                    paths[i].collect do |p|
                        a.gsub( /\n#{ i }\n/, p )
                    end
                end.flatten.uniq
            end
            all.collect do |path|
                yield YPath.new( path )
            end
        end
    end

end

Directory Contents

Dirs: 0 × Files: 14

Name Size Perms Modified Actions
4.85 KB lrw-r--r-- 2010-04-03 21:50:47
Edit Download
6.47 KB lrw-r--r-- 2010-07-19 04:54:06
Edit Download
1.16 KB lrw-r--r-- 2010-04-03 21:50:47
Edit Download
751 B lrw-r--r-- 2010-04-03 21:50:47
Edit Download
1.04 KB lrw-r--r-- 2010-04-03 21:50:47
Edit Download
296 B lrw-r--r-- 2010-04-03 21:50:47
Edit Download
14.49 KB lrw-r--r-- 2012-03-06 02:43:21
Edit Download
768 B lrw-r--r-- 2010-04-03 21:50:47
Edit Download
1.98 KB lrw-r--r-- 2010-04-03 21:50:47
Edit Download
194 B lrw-r--r-- 2011-05-15 11:55:52
Edit Download
3.16 KB lrw-r--r-- 2010-04-16 20:31:59
Edit Download
4.88 KB lrw-r--r-- 2010-04-03 21:50:47
Edit Download
1.19 KB lrw-r--r-- 2010-04-03 21:50:47
Edit Download
1.35 KB lrw-r--r-- 2010-04-03 21:50:47
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).