rviz 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/examples/hello.png CHANGED
Binary file
data/examples/hello.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  $:.unshift "lib", "../lib"
2
2
  require 'rviz'
3
3
 
4
- Rviz::Graph.new.add("Hello").add("World").link("Hello", "", "World").output
4
+ Rviz::Graph.new("Hello Word Example").add("Hello").add("World").link("Hello", "", "World").output
data/examples/record.rb CHANGED
@@ -4,7 +4,7 @@ require 'rviz'
4
4
 
5
5
  g = Rviz::Graph.new
6
6
  g.add(Rviz::Record.new('To', {color: 'blue'}))
7
- g.add(Rviz::Mrecord.new('Fu', {color: 'green'}))
7
+ g.add_mrecord('Fu', {color: 'green'})
8
8
 
9
9
  g.node('To').add_row("Hello").add_row("World", true)
10
10
  g.node('Fu').add_row("你好", true).add_row("世界")
data/lib/rviz/graph.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  module Rviz
2
2
  class Graph
3
- attr_accessor :subgraphs, :nodes, :edges
3
+ attr_accessor :title, :subgraphs, :nodes, :edges
4
4
 
5
- def initialize attrs = {}
5
+ def initialize title = '', attrs = {}
6
6
  @attrs = attrs
7
+ @title = title
7
8
  @nodes = Hash.new
8
9
  @edges = Array.new
9
10
  @links = Array.new
@@ -48,6 +49,20 @@ module Rviz
48
49
  self
49
50
  end
50
51
 
52
+ def add_subgraph
53
+ # TODO
54
+ end
55
+
56
+ def add_record name, attr = {}
57
+ @nodes[name] = Record.new(name, attr)
58
+ self
59
+ end
60
+
61
+ def add_mrecord name, attr = {}
62
+ @nodes[name] = Mrecord.new(name, attr)
63
+ self
64
+ end
65
+
51
66
  # create edge between two nodes
52
67
  def link from_name, from_anchor, to_name, to_anchor = "", attrs = {}
53
68
  @links << [from_name, from_anchor, to_name, to_anchor, attrs]
@@ -66,6 +81,12 @@ module Rviz
66
81
 
67
82
  fh.puts self.graph_start
68
83
  fh.puts self.graph_attr
84
+
85
+ if self.title.size > 0
86
+ fh.puts %Q{ labelloc = "t";}
87
+ fh.puts %Q{ label= "#{self.title}";}
88
+ end
89
+
69
90
  fh.puts self.node_attr
70
91
  fh.puts self.edge_attr
71
92
 
@@ -88,7 +109,7 @@ module Rviz
88
109
  end
89
110
  end
90
111
 
91
- class SubGraph
112
+ class SubGraph < Graph
92
113
  attr_accessor :name
93
114
  def graph_start; " subgraph #{self.name} {" end
94
115
  def graph_end; " }" end
data/lib/rviz/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Rviz
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rviz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: