class Macrocosm
Constants
- NoCategory
- VERSION
Attributes
curveness[R]
Public Class Methods
new(curveness: 0)
click to toggle source
# File lib/macrocosm.rb, line 54 def initialize(curveness: 0) category_index = -1 @categories = Hash.new{ |h, cate| h[cate] = (category_index += 1) } @nodes = [] @links = Links.new @curveness = curveness end
Public Instance Methods
add_link(source, target, relation_in_list: nil, relation_in_graph: nil, line_style: {})
click to toggle source
# File lib/macrocosm.rb, line 72 def add_link(source, target, relation_in_list: nil, relation_in_graph: nil, line_style: {}) @links.add_link( source, target, relation_in_list: relation_in_list, relation_in_graph: relation_in_graph, line_style: line_style ) end
add_node(name, category = nil)
click to toggle source
# File lib/macrocosm.rb, line 63 def add_node(name, category = nil) category = (category || NoCategory).to_s idx = @categories[category] @nodes << { name: name, category: idx } end
graph()
click to toggle source
# File lib/macrocosm.rb, line 89 def graph JSON.pretty_generate({ nodes: @nodes, links: @links.links, categories: @categories.keys.sort!.map{ |name| {name: name} } }) end
to_s()
click to toggle source
# File lib/macrocosm.rb, line 82 def to_s Template.new( graph: graph, curveness: curveness, ).render end