Sha256: bd53642cbf771d6de37718e7b55f50e931a036edd49c2d4757a29d77bb52ecbf

Contents?: true

Size: 515 Bytes

Versions: 5

Compression:

Stored size: 515 Bytes

Contents

module Cadet
  class PathTraverser
    include Enumerable

    def initialize(nodes, direction, type)
      @nodes = nodes
      @direction = direction
      @type = type
    end

    def each
      @nodes.each do |n|
        n.send(@direction, @type).each { |o| yield o }
      end
    end

    def outgoing(type)
      PathTraverser.new(to_a, :outgoing, type)
    end
    def incoming(type)
      PathTraverser.new(to_a, :incoming, type)
    end

    def ==(other)
      self.to_a == other.to_a
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cadet-0.1.4-java lib/cadet/path_traverser.rb
cadet-0.1.3-java lib/cadet/path_traverser.rb
cadet-0.1.2-java lib/cadet/path_traverser.rb
cadet-0.1.1-java lib/cadet/path_traverser.rb
cadet-0.1.0-java lib/cadet/path_traverser.rb