Sha256: ad25de06fdba59d6aed880eb44330f9ee416c26e95d16b02b22ab6bef5e9eddd

Contents?: true

Size: 504 Bytes

Versions: 13

Compression:

Stored size: 504 Bytes

Contents

$:.unshift( "../lib" )
require 'graphviz'

class Array
  def rotate
    ## Solution #1 by greg
    # self.push(r = self.shift)
    # return r
    
    ## Solution #2 by madx
    # shift.tap {|e| push e }
    
    ## Solution #3 by greg
    push(shift)[-1]
  end
end

type = ["box", "point"]

GraphViz.graph( :G, :use => :neato ) { |g|
  (1..5).each do |x|
    (1..5).each do |y|
      g.add_node( "n#{x}x#{y}", :pos => "#{x},#{y}!", :shape => type.rotate )
    end
  end  
}.output( :png => "#{$0}.png" )

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ruby-graphviz-1.0.2 examples/sample54.rb
ruby-graphviz-1.0.1 examples/sample54.rb
ruby-graphviz-1.0.0 examples/sample54.rb
ruby-graphviz-0.9.21 examples/sample54.rb
ruby-graphviz-0.9.20 examples/sample54.rb
ruby-graphviz-0.9.19 examples/sample54.rb
ruby-graphviz-0.9.18 examples/sample54.rb
ruby-graphviz-0.9.17 examples/sample54.rb
ruby-graphviz-0.9.16 examples/sample54.rb
ruby-graphviz-0.9.15 examples/sample54.rb
ruby-graphviz-0.9.14 examples/sample54.rb
ruby-graphviz-0.9.13 examples/sample54.rb
ruby-graphviz-0.9.12 examples/sample54.rb