class ChaosDetector::ChaosGraphs::FunctionNode

Attributes

root_node[R]
domain_name[RW]
fn_line[RW]
fn_line_end[RW]
fn_path[RW]
mod_infos[R]

Modules to which this Function Node is associated:

Public Class Methods

line_match?(l1, l2) click to toggle source
# File lib/chaos_detector/chaos_graphs/function_node.rb, line 104
def line_match?(l1, l2)
  return false if l1.nil? || l2.nil?

  (l2 - l1).between?(0, 1)
end
match?(obj1, obj2) click to toggle source
# File lib/chaos_detector/chaos_graphs/function_node.rb, line 94
def match?(obj1, obj2)
  raise 'Domains differ, but fn_info is the same.  Weird.' if \
    obj1.fn_name == obj2.fn_name \
    && obj1.fn_path == obj2.fn_path \
    && obj1.domain_name != other.domain_name

  fn_path == other.fn_path &&
    (fn_name == other.fn_name || line_match?(other.fn_line, fn_line))
end
new( fn_name: nil, fn_path: nil, fn_line: nil, domain_name: nil, is_root: false, mod_info: nil, reduction: nil ) click to toggle source
Calls superclass method ChaosDetector::GraphTheory::Node::new
# File lib/chaos_detector/chaos_graphs/function_node.rb, line 23
def initialize(
  fn_name: nil,
  fn_path: nil,
  fn_line: nil,
  domain_name: nil,
  is_root: false,
  mod_info: nil,
  reduction: nil
)
  super(name: fn_name, root: is_root, reduction: reduction)

  @domain_name = domain_name&.to_s
  @fn_path = fn_path
  @fn_line = fn_line
  @mod_infos = []

  # Add module info, if supplied:
  add_module(mod_info)
end

Public Instance Methods

==(other) click to toggle source
# File lib/chaos_detector/chaos_graphs/function_node.rb, line 59
def ==(other)
  ChaosDetector::Stacker::FnInfo.match?(self, other)
end
add_module(mod_info) click to toggle source
# File lib/chaos_detector/chaos_graphs/function_node.rb, line 43
def add_module(mod_info)
  @mod_infos << mod_info if mod_info
end
add_module_attrs(mod_name:, mod_path:, mod_type:) click to toggle source
# File lib/chaos_detector/chaos_graphs/function_node.rb, line 47
def add_module_attrs(mod_name:, mod_path:, mod_type:)
  add_module(ChaosDetector::Stacker::ModInfo.new(mod_name: mod_name, mod_path: mod_path, mod_type: mod_type))
end
eql?(other) click to toggle source
# File lib/chaos_detector/chaos_graphs/function_node.rb, line 55
def eql?(other)
  self == other
end
hash() click to toggle source
# File lib/chaos_detector/chaos_graphs/function_node.rb, line 51
def hash
  [fn_name, fn_path].hash
end
short_path() click to toggle source
# File lib/chaos_detector/chaos_graphs/function_node.rb, line 83
def short_path
  ChaosDetector::Utils::StrUtil.humanize_module(@fn_path, sep_token: '/')
end
subtitle() click to toggle source
# File lib/chaos_detector/chaos_graphs/function_node.rb, line 79
def subtitle
  '(%s)%s' % [domain_name, short_path]
end
title() click to toggle source
# File lib/chaos_detector/chaos_graphs/function_node.rb, line 75
def title
  fn_name
end
to_info() click to toggle source
# File lib/chaos_detector/chaos_graphs/function_node.rb, line 71
def to_info
  FnInfo.new(fn_name: fn_name, fn_line: fn_line, fn_path: fn_path)
end
to_s() click to toggle source
Calls superclass method ChaosDetector::GraphTheory::Node#to_s
# File lib/chaos_detector/chaos_graphs/function_node.rb, line 67
def to_s
  ChaosUtils.decorate_tuple([domain_name, fn_name, super, short_path], clamp: :bracket)
end