Sha256: 9e34577d70ce204e845120acf87f3fcdaf6eb80ed1a517bd4d5202e17378b6de
Contents?: true
Size: 725 Bytes
Versions: 7
Compression:
Stored size: 725 Bytes
Contents
module EndState class Graph < GraphViz attr_reader :machine, :nodes, :event_labels def initialize(machine, event_labels=true) @machine = machine @nodes = {} @event_labels = event_labels super machine.name.to_sym end def draw machine.transitions.keys.each do |t| left, right = t.to_a.flatten nodes[left] ||= add_node(left.to_s) nodes[right] ||= add_node(right.to_s) edge = add_edge nodes[left], nodes[right] if event_labels event = machine.events.detect do |event, transition| transition.include? t end edge[:label] = event.first.to_s if event end end self end end end
Version data entries
7 entries across 7 versions & 1 rubygems