Class: Yoda::Store::Objects::MethodObject
- Inherits:
-
Base
- Object
- Base
- Yoda::Store::Objects::MethodObject
show all
- Defined in:
- lib/yoda/store/objects/method_object.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#document, #path, #primary_source, #sources, #tag_list
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#==, #address, #eql?, #hash, #merge
#derive, included, #to_json
#address
Constructor Details
#initialize(parameters: [], visibility: :public, overloads: [], **kwargs) ⇒ MethodObject
Returns a new instance of MethodObject.
45
46
47
48
49
50
51
|
# File 'lib/yoda/store/objects/method_object.rb', line 45
def initialize(parameters: [], visibility: :public, overloads: [], **kwargs)
super(kwargs)
fail ArgumentError, visibility unless %i(public private protected)
@visibility = visibility.to_sym
@parameters = parameters
@overloads = overloads
end
|
Instance Attribute Details
#overloads ⇒ Array<Overload>
12
13
14
|
# File 'lib/yoda/store/objects/method_object.rb', line 12
def overloads
@overloads
end
|
#parameters ⇒ Array<(String, String)>
6
7
8
|
# File 'lib/yoda/store/objects/method_object.rb', line 6
def parameters
@parameters
end
|
#visibility ⇒ Symbol
9
10
11
|
# File 'lib/yoda/store/objects/method_object.rb', line 9
def visibility
@visibility
end
|
Class Method Details
.attr_names ⇒ Array<Symbol>
34
35
36
|
# File 'lib/yoda/store/objects/method_object.rb', line 34
def attr_names
super + %i(parameters visibility overloads)
end
|
.name_of_path(path) ⇒ String
23
24
25
|
# File 'lib/yoda/store/objects/method_object.rb', line 23
def name_of_path(path)
path.slice((path.rindex(/[#.]/) || -1) + 1, path.length)
end
|
.namespace_of_path(path) ⇒ String
17
18
19
|
# File 'lib/yoda/store/objects/method_object.rb', line 17
def namespace_of_path(path)
path.slice(0, (path.rindex(/[#.]/) || 0))
end
|
.sep_of_path(path) ⇒ String
29
30
31
|
# File 'lib/yoda/store/objects/method_object.rb', line 29
def sep_of_path(path)
path.slice(path.rindex(/[#.]/))
end
|
Instance Method Details
#kind ⇒ Object
68
69
70
|
# File 'lib/yoda/store/objects/method_object.rb', line 68
def kind
:method
end
|
#name ⇒ String
54
55
56
|
# File 'lib/yoda/store/objects/method_object.rb', line 54
def name
@name ||= MethodObject.name_of_path(path)
end
|
#namespace_path ⇒ String
64
65
66
|
# File 'lib/yoda/store/objects/method_object.rb', line 64
def namespace_path
@namespace_path ||= MethodObject.namespace_of_path(path)
end
|
#sep ⇒ String
59
60
61
|
# File 'lib/yoda/store/objects/method_object.rb', line 59
def sep
@sep ||= MethodObject.sep_of_path(path)
end
|
#to_h ⇒ Object
72
73
74
75
76
77
78
|
# File 'lib/yoda/store/objects/method_object.rb', line 72
def to_h
super.merge(
parameters: parameters.to_a,
visibility: visibility,
overloads: overloads,
)
end
|