Class: RDocF95::DOT::Node

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

Overview

node element

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 = NODE_OPTS) ⇒ Node

Returns a new instance of Node.



135
136
137
138
# File 'lib/rdoc-f95/dot.rb', line 135

def initialize( params = {}, option_list = NODE_OPTS )
  super( params, option_list )
  @ports = params['ports'] ? params['ports'] : []
end

Instance Method Details

#<<(thing) ⇒ Object



144
145
146
# File 'lib/rdoc-f95/dot.rb', line 144

def << ( thing )
  @ports << thing
end

#each_portObject



140
141
142
# File 'lib/rdoc-f95/dot.rb', line 140

def each_port
  @ports.each{ |i| yield i }
end

#popObject



152
153
154
# File 'lib/rdoc-f95/dot.rb', line 152

def pop
  @ports.pop
end

#push(thing) ⇒ Object



148
149
150
# File 'lib/rdoc-f95/dot.rb', line 148

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

#to_s(t = '') ⇒ Object



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/rdoc-f95/dot.rb', line 156

def to_s( t = '' )

  label = @options['shape'] != 'record' && @ports.length == 0 ?
    @options['label'] ?
    t + TAB + "label = \"#{@options['label']}\"\n" :
                '' :
                t + TAB + 'label = "' + " \\\n" +
                t + TAB2 + "#{@options['label']}| \\\n" +
                @ports.collect{ |i|
    t + TAB2 + i.to_s
  }.join( "| \\\n" ) + " \\\n" +
    t + TAB + '"' + "\n"

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