Class: DependencyGrapher::Method

Inherits:
Object
  • Object
show all
Includes:
SerializeHelpers
Defined in:
lib/dependency_grapher/method.rb

Constant Summary collapse

Limit =
50

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(defined_class, method_id, path, lineno) ⇒ Method

Returns a new instance of Method.



16
17
18
19
20
21
22
23
24
# File 'lib/dependency_grapher/method.rb', line 16

def initialize(defined_class, method_id, path, lineno)
  # Truncate class name to limit characters if too long
  defined_class = defined_class[0,Limit] + "..." if defined_class.length > Limit
  @defined_class = defined_class
  @method_id = method_id
  @path = path
  @lineno = lineno
  @types = Set.new
end

Instance Attribute Details

#defined_classObject (readonly)

Returns the value of attribute defined_class.



11
12
13
# File 'lib/dependency_grapher/method.rb', line 11

def defined_class
  @defined_class
end

#linenoObject (readonly)

Returns the value of attribute lineno.



11
12
13
# File 'lib/dependency_grapher/method.rb', line 11

def lineno
  @lineno
end

#method_idObject (readonly)

Returns the value of attribute method_id.



11
12
13
# File 'lib/dependency_grapher/method.rb', line 11

def method_id
  @method_id
end

#pathObject (readonly)

Returns the value of attribute path.



11
12
13
# File 'lib/dependency_grapher/method.rb', line 11

def path
  @path
end

#typesObject

TODO Fix LOD violation (types should not be directly exposed)



14
15
16
# File 'lib/dependency_grapher/method.rb', line 14

def types
  @types
end

Instance Method Details

#ancestorsObject



30
31
32
33
# File 'lib/dependency_grapher/method.rb', line 30

def ancestors
  binding.pry if @defined_class.nil?
  @defined_class.split("::")
end

#full_pathObject



26
27
28
# File 'lib/dependency_grapher/method.rb', line 26

def full_path
  @path + ":" + @lineno
end

#idObject



43
44
45
# File 'lib/dependency_grapher/method.rb', line 43

def id
  @defined_class + @method_id
end

#leafObject



39
40
41
# File 'lib/dependency_grapher/method.rb', line 39

def leaf
  ancestors.last
end

#rootObject



35
36
37
# File 'lib/dependency_grapher/method.rb', line 35

def root
  ancestors.first
end