Class: NetworkDrawer::Element::Node

Inherits:
NetworkDrawer::Element show all
Defined in:
lib/network_drawer/element/node.rb

Overview

Replesent of node

Constant Summary collapse

DEFAULT_STYLE =
{ fontname: 'Helvetica', shape: 'box' }

Instance Method Summary collapse

Constructor Details

#initialize(initial_values = {}, style = {}) ⇒ Node

Returns a new instance of Node.



9
10
11
12
# File 'lib/network_drawer/element/node.rb', line 9

def initialize(initial_values = {}, style = {})
  super
  @default_style = DEFAULT_STYLE
end

Instance Method Details

#to_codeObject



14
15
16
17
18
19
20
# File 'lib/network_drawer/element/node.rb', line 14

def to_code
  style = style(self.type).dup
  style.merge!(self.to_hash)
  style.merge!(label: build_label, tooltip: self.name, URL: self.url )
  style.merge!(ports: nil)
  "node(:\"#{self.id}\", #{style})"
end