class Compath::GuideBook

Attributes

paths[R]

Public Class Methods

new(guides) click to toggle source
# File lib/compath/guide_book.rb, line 4
def initialize(guides)
  @index = guides.each_with_object({}) do |guide, hash|
    hash[guide.to_path] = guide
  end
end

Public Instance Methods

guides() click to toggle source
# File lib/compath/guide_book.rb, line 10
def guides
  @index.values
end
merge(new_guides) click to toggle source
# File lib/compath/guide_book.rb, line 14
def merge(new_guides)
  new_guides.each do |guide|
    if @index.key?(guide.to_path)
      @index[guide.to_path] = guide
    end
  end
end
publish() click to toggle source
# File lib/compath/guide_book.rb, line 22
def publish
  @index.each_with_object({}) do |(path, guide), hash|
    scan_children = true
    scan_children = guide.ancestors.all? do |ancestor|
      @index[ancestor.to_path].scan_children
    end
    next unless scan_children

    hash.update(guide.to_object)
  end
end
publish_yaml() click to toggle source
# File lib/compath/guide_book.rb, line 34
def publish_yaml
  YAML.dump(publish)
end