class VisualizeRuby::Node
Attributes
id[RW]
label[R]
line[R]
lineno_connection[RW]
style[R]
type[RW]
Public Class Methods
new(name: nil, type: :action, style: :rounded, ast: nil, line: nil, id: nil, **opts)
click to toggle source
# File lib/visualize_ruby/node.rb, line 9 def initialize(name: nil, type: :action, style: :rounded, ast: nil, line: nil, id: nil, **opts) @label = name || (ast ? AstHelper.new(ast).description : nil) @type = type @style = style @id = id || (ast ? AstHelper.new(ast).id : @label) @line = line || AstHelper.new(ast).first_line post_initialize(opts) end
Public Instance Methods
==(other)
click to toggle source
# File lib/visualize_ruby/node.rb, line 50 def ==(other) other.class == self.class && other.hash == self.hash end
Also aliased as: eql?
hash()
click to toggle source
# File lib/visualize_ruby/node.rb, line 56 def hash [type, name, style, id].hash end
inspect()
click to toggle source
# File lib/visualize_ruby/node.rb, line 46 def inspect "#<VisualizeRuby::Node #{type_display} #{id}>" end
Also aliased as: to_s
shape()
click to toggle source
# File lib/visualize_ruby/node.rb, line 33 def shape case type when :decision :diamond when :action :ellipse when :argument :box else :box end end
to_a()
click to toggle source
# File lib/visualize_ruby/node.rb, line 18 def to_a [type, name.to_s] end
type_display()
click to toggle source
# File lib/visualize_ruby/node.rb, line 22 def type_display case type when :decision "<>" when :action "[]" when :argument "[>" end end