class JekyllRPG::Graph
Graph
of relationships between CollectionDocuments
Attributes
edges[RW]
Public Class Methods
new()
click to toggle source
# File lib/graph.rb, line 8 def initialize @edges = [] end
Public Instance Methods
document_references(doc)
click to toggle source
Get the information for every page the current doc is referenced in And push links to an array that represents the collections of those pages
# File lib/graph.rb, line 14 def document_references(doc) document_hash = {} referenced_in(doc).each do |reference| document_hash[reference.collection] = [] unless document_hash.key?(reference.collection) document_hash[reference.collection].push(reference.markdown_link) end document_hash.each do |k, v| document_hash[k] = v.uniq end document_hash end
hash()
click to toggle source
# File lib/graph.rb, line 44 def hash @edges.map(&:hash) end
referenced_in(doc)
click to toggle source
Based on the graph, returns edges that a specific document is the referent of
# File lib/graph.rb, line 29 def referenced_in(doc) collection = doc.collection.label slug = doc.data['slug'] @edges.select do |edge| edge.reference.collection == collection && edge.reference.slug == slug end.map(&:referent) end
unviewable()
click to toggle source
Based on the graph, returns documents that are referenced, but do not exist yet
# File lib/graph.rb, line 38 def unviewable @edges.reject do |edge| edge.reference.viewable end end