Sha256: 4f5b5711d8e7eeb6ab90c12f7ff7f7087ba89972f4f5e1b7b4b766dff3bf6feb

Contents?: true

Size: 1.61 KB

Versions: 29

Compression:

Stored size: 1.61 KB

Contents

module Pacer
  module Core
    module Route
      def paths(*exts)
        route = chain_route :transform => :path, :element_type => :path
        if exts.any?
          exts = exts.map { |e| Array.wrap(e) if e }
          route.map(element_type: :path) do |path|
            path.zip(exts).map { |element, ext| ext ? element.add_extensions(ext) : element }
          end
        else
          route
        end
      end
    end
  end

  module Transform
    module Path
      import com.tinkerpop.pipes.transform.PathPipe

      def help(section = nil)
        case section
        when nil
          puts <<HELP
Each path returned by this method represents each intermediate value that was
used to calculate the resulting value:

  r = [1,2,3].to_route.map { |n| n*2 }
  p = r.paths                           #=> #<Obj -> Obj-Map -> Path-Path>
  p.to_a                                #=> [[1,1], [2,4], [3,6]]

This is especially useful for graph traversals.

  g.v.out_e.in_v.out_e.in_v.paths.first #=> [#<V[37]>,
                                        #    #<E[41]:37-patcit-38>,
                                        #    #<V[38]>,
                                        #    #<E[40]:38-document-id-39>,
                                        #    #<V[39]>]

See:
  :paths  - for more details and general information about paths.
  :arrays - for general operations that work on arrays or paths.

HELP
        else
          super
        end
        description
      end

      protected

      def attach_pipe(end_pipe)
        pipe = PathPipe.new
        pipe.setStarts end_pipe if end_pipe
        pipe
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
pacer-2.0.24-java lib/pacer/transform/path.rb
pacer-2.0.22-java lib/pacer/transform/path.rb
pacer-2.0.20-java lib/pacer/transform/path.rb
pacer-2.0.19-java lib/pacer/transform/path.rb
pacer-2.0.18-java lib/pacer/transform/path.rb
pacer-2.0.17-java lib/pacer/transform/path.rb
pacer-2.0.16-java lib/pacer/transform/path.rb
pacer-2.0.15-java lib/pacer/transform/path.rb
pacer-2.0.14-java lib/pacer/transform/path.rb
pacer-2.0.13-java lib/pacer/transform/path.rb
pacer-2.0.12-java lib/pacer/transform/path.rb
pacer-2.0.10-java lib/pacer/transform/path.rb
pacer-2.0.10.pre-java lib/pacer/transform/path.rb
pacer-2.0.8-java lib/pacer/transform/path.rb
pacer-2.0.6-java lib/pacer/transform/path.rb
pacer-2.0.4.pre-java lib/pacer/transform/path.rb
pacer-2.0.0.pre-java lib/pacer/transform/path.rb
pacer-1.6.0-java lib/pacer/transform/path.rb
pacer-1.5.4-java lib/pacer/transform/path.rb
pacer-1.5.3-java lib/pacer/transform/path.rb