Class: ComponentLink

Inherits:
Object
  • Object
show all
Defined in:
lib/cpp_dependency_graph/component_link.rb

Instance Method Summary collapse

Constructor Details

#initialize(source, target, cyclic = false) ⇒ ComponentLink



6
7
8
9
10
# File 'lib/cpp_dependency_graph/component_link.rb', line 6

def initialize(source, target, cyclic = false)
  @source = source
  @target = target
  @cyclic = cyclic
end

Instance Method Details

#cyclic?Boolean



20
21
22
# File 'lib/cpp_dependency_graph/component_link.rb', line 20

def cyclic?
  @cyclic
end

#sourceObject



12
13
14
# File 'lib/cpp_dependency_graph/component_link.rb', line 12

def source
  @source
end

#targetObject



16
17
18
# File 'lib/cpp_dependency_graph/component_link.rb', line 16

def target
  @target
end

#to_json(*a) ⇒ Object



32
33
34
35
36
# File 'lib/cpp_dependency_graph/component_link.rb', line 32

def to_json(*a)
  { json_class: self.class.name,
    source: source, target: target, cyclic: cyclic?
  }.to_json(*a)
end

#to_sObject



24
25
26
27
28
29
30
# File 'lib/cpp_dependency_graph/component_link.rb', line 24

def to_s
  if cyclic?
    "#{source} <-> #{target}"
  else
    "#{source} -> #{target}"
  end
end