Class: RubyDetective::AST::Nodes::GenericNode
- Inherits:
-
Object
- Object
- RubyDetective::AST::Nodes::GenericNode
show all
- Defined in:
- lib/ruby_detective/ast/nodes/generic_node.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(ast_node, file_path:, parent_node:) ⇒ GenericNode
Returns a new instance of GenericNode.
7
8
9
10
11
12
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 7
def initialize(ast_node, file_path:, parent_node:)
@ast_node = ast_node
@file_path = file_path
@children = []
@parent_node = parent_node
end
|
Instance Attribute Details
#ast_node ⇒ Object
Returns the value of attribute ast_node.
5
6
7
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 5
def ast_node
@ast_node
end
|
#children ⇒ Object
Returns the value of attribute children.
5
6
7
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 5
def children
@children
end
|
#file_path ⇒ Object
Returns the value of attribute file_path.
5
6
7
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 5
def file_path
@file_path
end
|
#parent_node ⇒ Object
Returns the value of attribute parent_node.
5
6
7
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 5
def parent_node
@parent_node
end
|
Instance Method Details
#absolute_path_sign_node? ⇒ Boolean
38
39
40
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 38
def absolute_path_sign_node?
type == :absolute_path_sign
end
|
#class_declaration_node? ⇒ Boolean
26
27
28
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 26
def class_declaration_node?
type == :class
end
|
#constant_reference_node? ⇒ Boolean
34
35
36
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 34
def constant_reference_node?
type == :constant
end
|
#declared_namespace ⇒ Object
22
23
24
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 22
def declared_namespace
[]
end
|
#first_line ⇒ Object
54
55
56
57
58
59
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 54
def first_line
ast_node.loc.line rescue nil
end
|
#generic_node? ⇒ Boolean
46
47
48
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 46
def generic_node?
type == :generic
end
|
#last_line ⇒ Object
61
62
63
64
65
66
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 61
def last_line
ast_node.loc.last_line rescue nil
end
|
#module_declaration_node? ⇒ Boolean
30
31
32
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 30
def module_declaration_node?
type == :module
end
|
#namespace ⇒ Object
18
19
20
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 18
def namespace
build_namespace(self)
end
|
#query ⇒ Object
68
69
70
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 68
def query
Query.new(self)
end
|
#raw_children ⇒ Object
72
73
74
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 72
def raw_children
ast_node.children
end
|
#short_namespace ⇒ Object
14
15
16
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 14
def short_namespace
namespace[0..-2]
end
|
#type ⇒ Object
50
51
52
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 50
def type
:generic
end
|
#value_node? ⇒ Boolean
42
43
44
|
# File 'lib/ruby_detective/ast/nodes/generic_node.rb', line 42
def value_node?
type == :value
end
|