Method: FSM::FSM#plot
- Defined in:
- lib/fsm-0.0.0/fsm.rb
#plot(dot_in = nil, dot_out = nil, fmt = 'jpg', &b) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/fsm-0.0.0/fsm.rb', line 171 def plot dot_in = nil, dot_out = nil, fmt = 'jpg', &b dot_in ||= (tmp = Tempfile.new("#{ Process.pid }-#{ Time.now.to_i }-#{ rand }")).path if tmp tmp.puts to_dot tmp.close else open(dot_in, 'w'){|f| f.puts to_dot} end dot_out = dot_in + '.' + fmt cmd = "#{ DOT_CMD } -T#{ fmt } #{ dot_in } -o #{ dot_out }" system cmd or raise "cmd <#{ cmd } failed with <#{ $?.exitstatus }>" dot_out end |