Class: RubyToUML::UMLInfoGenerator::NodeFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_to_uml/uml_info_generator/processor_helpers.rb

Class Method Summary collapse

Class Method Details

.arguments(node) ⇒ Object



119
120
121
122
123
# File 'lib/ruby_to_uml/uml_info_generator/processor_helpers.rb', line 119

def arguments(node)
  return [] if node.children.nil?

  node.children.each_with_object([]) { |node, args| args << node.children[0] }
end

.class_body(node) ⇒ Object



75
76
77
78
# File 'lib/ruby_to_uml/uml_info_generator/processor_helpers.rb', line 75

def class_body(node)
  body_node_index = 2
  node.children[body_node_index]
end

.class_name(node) ⇒ Object



70
71
72
73
# File 'lib/ruby_to_uml/uml_info_generator/processor_helpers.rb', line 70

def class_name(node)
  constant, inherit, children = *node
  NodeFinder.constant_name(constant)
end

.constant_name(const_node) ⇒ Object



85
86
87
88
# File 'lib/ruby_to_uml/uml_info_generator/processor_helpers.rb', line 85

def constant_name(const_node)
  constant_name_index = 1
  const_node.children[constant_name_index]
end

.instance_method_args(def_node) ⇒ Object



95
96
97
98
# File 'lib/ruby_to_uml/uml_info_generator/processor_helpers.rb', line 95

def instance_method_args(def_node)
  args_index = 1
  NodeFinder.arguments(def_node.children[args_index])
end

.instance_variable_name(node) ⇒ Object



130
131
132
133
# File 'lib/ruby_to_uml/uml_info_generator/processor_helpers.rb', line 130

def instance_variable_name(node)
  name_index = 0
  node.children[name_index]
end

.method_body_node(def_node) ⇒ Object



125
126
127
128
# File 'lib/ruby_to_uml/uml_info_generator/processor_helpers.rb', line 125

def method_body_node(def_node)
  body_index = 2
  def_node.children[body_index]
end

.method_name(def_node) ⇒ Object



90
91
92
93
# File 'lib/ruby_to_uml/uml_info_generator/processor_helpers.rb', line 90

def method_name(def_node)
  name_index = 0
  def_node.children[name_index]
end

.method_type_change(method_name) ⇒ Object



105
106
107
# File 'lib/ruby_to_uml/uml_info_generator/processor_helpers.rb', line 105

def method_type_change(method_name)
  %i[public private protected].include?(method_name) ? method_name : nil
end

.module_body(node) ⇒ Object



140
141
142
143
# File 'lib/ruby_to_uml/uml_info_generator/processor_helpers.rb', line 140

def module_body(node)
  _, body = *node
  body
end

.module_name(node) ⇒ Object



135
136
137
138
# File 'lib/ruby_to_uml/uml_info_generator/processor_helpers.rb', line 135

def module_name(node)
  constant, = *node
  NodeFinder.constant_name(constant)
end

.send_method(send_node) ⇒ Object



100
101
102
103
# File 'lib/ruby_to_uml/uml_info_generator/processor_helpers.rb', line 100

def send_method(send_node)
  caller, method, arguments = *send_node
  method
end

.singleton_method_args(defs_node) ⇒ Object



114
115
116
117
# File 'lib/ruby_to_uml/uml_info_generator/processor_helpers.rb', line 114

def singleton_method_args(defs_node)
  args_index = 2
  NodeFinder.arguments(defs_node.children[args_index])
end

.singleton_method_name(defs_node) ⇒ Object



109
110
111
112
# File 'lib/ruby_to_uml/uml_info_generator/processor_helpers.rb', line 109

def singleton_method_name(defs_node)
  name_index = 1
  defs_node.children[name_index]
end

.superclass_name(node) ⇒ Object



80
81
82
83
# File 'lib/ruby_to_uml/uml_info_generator/processor_helpers.rb', line 80

def superclass_name(node)
  constant, inherit, children = *node
  inherit ? NodeFinder.constant_name(inherit) : nil
end