Sha256: 20aef7669c3b13069cbca39c3ecb4c6a34b603a3809971c1804c161ff4574459

Contents?: true

Size: 354 Bytes

Versions: 1

Compression:

Stored size: 354 Bytes

Contents

require 'dag'

module ChoresKit
  class DAG < ::DAG
    def root
      return @vertices.first if @root.nil? && @edges.empty?

      @root || @vertices.detect { |v| v.ancestors.empty? && v.successors.any? }
    end

    def root!(vertex)
      @root = vertex
    end

    def find_by(name:)
      @vertices.detect { |v| v.name == name }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chores_kit-0.2.5 lib/chores_kit/chore/dag.rb