Class: ChaosDetector::ChaosGraphs::DomainNode

Inherits:
GraphTheory::Node show all
Defined in:
lib/chaos_detector/chaos_graphs/domain_node.rb

Constant Summary

Constants inherited from GraphTheory::Node

GraphTheory::Node::ROOT_NODE_NAME

Class Attribute Summary collapse

Attributes inherited from GraphTheory::Node

#is_root, #node_origin, #reduction

Instance Method Summary collapse

Methods inherited from GraphTheory::Node

#merge!, #name, #root?, #to_k

Constructor Details

#initialize(domain_name: nil, node_origin: nil, is_root: false, reduction: nil) ⇒ DomainNode

Returns a new instance of DomainNode.



8
9
10
# File 'lib/chaos_detector/chaos_graphs/domain_node.rb', line 8

def initialize(domain_name: nil, node_origin: nil, is_root: false, reduction: nil)
  super(name: domain_name, root: is_root, node_origin: node_origin, reduction: reduction)
end

Class Attribute Details

.root_node(force_new: false) ⇒ Object (readonly)

Returns the value of attribute root_node.



49
50
51
# File 'lib/chaos_detector/chaos_graphs/domain_node.rb', line 49

def root_node
  @root_node
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
# File 'lib/chaos_detector/chaos_graphs/domain_node.rb', line 20

def ==(other)
  domain_name&.to_s == other&.domain_name&.to_s
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/chaos_detector/chaos_graphs/domain_node.rb', line 16

def eql?(other)
  self == other
end

#graph_propsObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/chaos_detector/chaos_graphs/domain_node.rb', line 32

def graph_props
  props = super
  if reduction
    props.merge!(
      cardinality_modules: reduction.reduction_count,
      cardinality_functions: reduction.reduction_sum
    )
  end
  super.merge(props)
end

#hashObject



12
13
14
# File 'lib/chaos_detector/chaos_graphs/domain_node.rb', line 12

def hash
  domain_name.hash
end

#subtitleObject



28
29
30
# File 'lib/chaos_detector/chaos_graphs/domain_node.rb', line 28

def subtitle
  root? ? 'Root Node' : ''
end

#titleObject



24
25
26
# File 'lib/chaos_detector/chaos_graphs/domain_node.rb', line 24

def title
  super
end

#to_sObject

Must be name/domain_name for comparisons:



44
45
46
# File 'lib/chaos_detector/chaos_graphs/domain_node.rb', line 44

def to_s
  domain_name
end