class Link

Represents a link between two entities, a source and a target

Attributes

source[R]
target[R]

Public Class Methods

new(source, target, cyclic = false) click to toggle source
# File lib/cpp_dependency_graph/link.rb, line 11
def initialize(source, target, cyclic = false)
  @source = source
  @target = target
  @cyclic = cyclic
end

Public Instance Methods

==(other) click to toggle source
# File lib/cpp_dependency_graph/link.rb, line 21
def ==(other)
  (source == other.source && target == other.target && cyclic? == other.cyclic?) ||
    (source == other.target && target == other.source && cyclic? == other.cyclic?)
end
cyclic?() click to toggle source
# File lib/cpp_dependency_graph/link.rb, line 17
def cyclic?
  @cyclic
end
hash() click to toggle source
# File lib/cpp_dependency_graph/link.rb, line 26
def hash
  [source, target, cyclic?].to_set.hash
end
to_json(*options) click to toggle source
# File lib/cpp_dependency_graph/link.rb, line 38
def to_json(*options)
  { json_class: self.class.name,
    source: source, target: target, cyclic: cyclic? }.to_json(*options)
end
to_s() click to toggle source
# File lib/cpp_dependency_graph/link.rb, line 30
def to_s
  if cyclic?
    "#{source} <-> #{target}"
  else
    "#{source} -> #{target}"
  end
end