Class: DuckTesting::YARD::MethodObject
Overview
Encapsulate YARD::CodeObjects::MethodObject
.
Instance Attribute Summary collapse
Attributes inherited from CodeObject
#path, #yard_object
Instance Method Summary
collapse
Methods inherited from CodeObject
#initialize
Instance Attribute Details
#name ⇒ String
Returns the name of the object.
15
|
# File 'lib/duck_testing/yard/method_object.rb', line 15
def_delegators :@yard_object, "name", "scope"
|
#scope ⇒ Symbol
Returns the scope of the object.
15
|
# File 'lib/duck_testing/yard/method_object.rb', line 15
def_delegators :@yard_object, "name", "scope"
|
Instance Method Details
53
54
55
|
# File 'lib/duck_testing/yard/method_object.rb', line 53
def expected_return_types
return_tag ? DuckTesting::YARD.expected_types(return_tag.types) : []
end
|
43
44
45
|
# File 'lib/duck_testing/yard/method_object.rb', line 43
def keyword_parameters
method_parameters.select(&:keyword?)
end
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/duck_testing/yard/method_object.rb', line 23
def method_parameters
@method_parameters ||= begin
if yard_object.parameters.any?
yard_object.parameters.map do |name, default|
MethodParameter.new(self, name, default, get_parameter_tag(name))
end
elsif parameter_tags.any?
parameter_tags.map do |tag|
MethodParameter.new(self, tag.name, nil, tag)
end
else
[]
end
end
end
|
#public_class_method? ⇒ Boolean
63
64
65
|
# File 'lib/duck_testing/yard/method_object.rb', line 63
def public_class_method?
yard_object.scope == :class
end
|
#public_instance_method? ⇒ Boolean
58
59
60
|
# File 'lib/duck_testing/yard/method_object.rb', line 58
def public_instance_method?
yard_object.scope == :instance
end
|
#return_tag ⇒ YARD::Tags::Tag
48
49
50
|
# File 'lib/duck_testing/yard/method_object.rb', line 48
def return_tag
@return_tag ||= yard_object.tags.find { |tag| tag.tag_name == "return" }
end
|
#signature ⇒ String
18
19
20
|
# File 'lib/duck_testing/yard/method_object.rb', line 18
def signature
"#{name}(#{parameters_signature})"
end
|