Class: NetworkDrawer::Element::Connection

Inherits:
Element
  • Object
show all
Defined in:
lib/network_drawer/element/connection.rb

Overview

Replesent of connection

Constant Summary collapse

DEFAULT_STYLE =
{}

Instance Method Summary collapse

Methods inherited from Element

generate_id, #to_hash

Constructor Details

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

Returns a new instance of Connection.



9
10
11
12
# File 'lib/network_drawer/element/connection.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
# File 'lib/network_drawer/element/connection.rb', line 14

def to_code
  style = style(self.type).dup
  style.merge!(self.to_hash)
  cid = "#{self.from}_#{self.to}_#{self.id}".gsub('/', '').to_sym
  "edge(:\"#{cid}\", #{style})\n"
end