123456789_123456789_123456789_123456789_123456789_

Class: Prism::DotVisitor::Table

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: lib/prism/dot_visitor.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(name) ⇒ Table

[ GitHub ]

  
# File 'lib/prism/dot_visitor.rb', line 40

def initialize(name)
  @name = name
  @fields = []
end

Instance Attribute Details

#fields (readonly)

[ GitHub ]

  
# File 'lib/prism/dot_visitor.rb', line 38

attr_reader :name, :fields

#name (readonly)

[ GitHub ]

  
# File 'lib/prism/dot_visitor.rb', line 38

attr_reader :name, :fields

Instance Method Details

#field(name, value = nil, port: false)

[ GitHub ]

  
# File 'lib/prism/dot_visitor.rb', line 45

def field(name, value = nil, port: false)
  fields << Field.new(name, value, port)
end

#to_dot

[ GitHub ]

  
# File 'lib/prism/dot_visitor.rb', line 49

def to_dot
  dot = <<~DOT
    <table border="0" cellborder="1" cellspacing="0" cellpadding="4">
      <tr><td colspan="2"><b>#{name}</b></td></tr>
  DOT

  if fields.any?
    "#{dot}  #{fields.map(&:to_dot).join("\n  ")}\n</table>"
  else
    "#{dot}</table>"
  end
end