Class: RDocF95::DOT::Subgraph

Inherits:
Element show all
Defined in:
lib/rdoc-f95/dot.rb

Overview

subgraph element is the same to graph, but has another header in dot notation

Direct Known Subclasses

Digraph

Instance Attribute Summary

Attributes inherited from Element

#name, #options

Attributes inherited from SimpleElement

#name

Instance Method Summary collapse

Methods inherited from Element

#each_option, #each_option_pair

Constructor Details

#initialize(params = {}, option_list = GRAPH_OPTS) ⇒ Subgraph

Returns a new instance of Subgraph.



183
184
185
186
187
# File 'lib/rdoc-f95/dot.rb', line 183

def initialize( params = {}, option_list = GRAPH_OPTS )
  super( params, option_list )
  @nodes = params['nodes'] ? params['nodes'] : []
  @dot_string = 'subgraph'
end

Instance Method Details

#<<(thing) ⇒ Object



193
194
195
# File 'lib/rdoc-f95/dot.rb', line 193

def << ( thing )
  @nodes << thing
end

#each_nodeObject



189
190
191
# File 'lib/rdoc-f95/dot.rb', line 189

def each_node
  @nodes.each{ |i| yield i }
end

#popObject



201
202
203
# File 'lib/rdoc-f95/dot.rb', line 201

def pop
  @nodes.pop
end

#push(thing) ⇒ Object



197
198
199
# File 'lib/rdoc-f95/dot.rb', line 197

def push( thing )
  @nodes.push( thing )
end

#to_s(t = '') ⇒ Object



205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/rdoc-f95/dot.rb', line 205

def to_s( t = '' )
  hdr = t + "#{@dot_string} #{@name} {\n"

  options = @options.to_a.collect{ |name, val|
    val && name != 'label' ?
      t + TAB + "#{name} = #{val}" :
    name ? t + TAB + "#{name} = \"#{val}\"" : nil
  }.compact.join( "\n" ) + "\n"

  nodes = @nodes.collect{ |i|
    i.to_s( t + TAB )
  }.join( "\n" ) + "\n"
  hdr + options + nodes + t + "}\n"
end