class Picatrix::Pacman
eats dots :) and gives you back nodes and edges
Attributes
edges[RW]
nodes[RW]
Public Class Methods
new(file_name)
click to toggle source
# File lib/picatrix/pacman.rb, line 7 def initialize(file_name) hash = TransformToHash.new.apply( DigraphParser.new.parse( File.read(file_name) ) ).flat_map(&:entries). group_by(&:first). map {|k,v| Hash[k, v.map(&:last)]}. reduce({}, :merge) @nodes = hash[:node].reduce({}, :merge) @edges = hash[:edge] end
Public Instance Methods
graph_hash()
click to toggle source
# File lib/picatrix/pacman.rb, line 21 def graph_hash { node: nodes, edge: edges } end