class Hashematics::Graph
Graph
serves as the main point of entry for this system. Basic use:
Attributes
group_dictionary[R]
record_set[R]
Public Class Methods
new(groups = [])
click to toggle source
# File lib/hashematics/graph.rb, line 23 def initialize(groups = []) @group_dictionary = Dictionary.new.add(groups, &:name) @record_set = RecordSet.new freeze end
Public Instance Methods
add(enumerable)
click to toggle source
# File lib/hashematics/graph.rb, line 30 def add(enumerable) enumerable.each { |object| add_one(object) } self end
children()
click to toggle source
# File lib/hashematics/graph.rb, line 36 def children group_dictionary.map(&:name) end
data(name)
click to toggle source
# File lib/hashematics/graph.rb, line 44 def data(name) visit(name).map { |v| v.data(true) } end
visit(name)
click to toggle source
# File lib/hashematics/graph.rb, line 40 def visit(name) group(name)&.visit || [] end
Private Instance Methods
add_one(object)
click to toggle source
# File lib/hashematics/graph.rb, line 54 def add_one(object) record = record_set.add(object) group_dictionary.each do |group| group.add(record) end end
group(name)
click to toggle source
# File lib/hashematics/graph.rb, line 50 def group(name) group_dictionary.get(name) end