Class: Inch::CodeObject::Proxy::MethodParameterObject
- Inherits:
-
Object
- Object
- Inch::CodeObject::Proxy::MethodParameterObject
- Defined in:
- lib/inch/code_object/proxy/method_parameter_object.rb
Overview
Proxy class for method parameters
Constant Summary collapse
- BAD_NAME_EXCEPTIONS =
%w(id)
- BAD_NAME_THRESHOLD =
3
Instance Attribute Summary collapse
- #name ⇒ String readonly
Instance Method Summary collapse
-
#bad_name? ⇒ Boolean
true
if the name of the parameter is uncommunicative. -
#block? ⇒ Boolean
true
if the parameter is a block. -
#described? ⇒ Boolean
true
if an additional description given?. -
#initialize(method, name, tag, in_signature) ⇒ MethodParameterObject
constructor
A new instance of MethodParameterObject.
-
#mentioned? ⇒ Boolean
true
if the parameter is mentioned in the docs. -
#splat? ⇒ Boolean
true
if the parameter is a splat argument. -
#typed? ⇒ Boolean
true
if the type of the parameter is defined. -
#wrongly_mentioned? ⇒ Boolean
true
if the parameter is mentioned in the docs, but not present in the method’s signature.
Constructor Details
#initialize(method, name, tag, in_signature) ⇒ MethodParameterObject
Returns a new instance of MethodParameterObject.
12 13 14 15 16 17 |
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 12 def initialize(method, name, tag, in_signature) @method = method @name = name @tag = tag @in_signature = in_signature end |
Instance Attribute Details
#name ⇒ String (readonly)
6 7 8 |
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 6 def name @name end |
Instance Method Details
#bad_name? ⇒ Boolean
Returns true
if the name of the parameter is uncommunicative.
23 24 25 26 |
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 23 def bad_name? return false if BAD_NAME_EXCEPTIONS.include?(name) name.size < BAD_NAME_THRESHOLD || name =~ /[0-9]$/ end |
#block? ⇒ Boolean
Returns true
if the parameter is a block.
29 30 31 |
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 29 def block? name =~ /^\&/ end |
#described? ⇒ Boolean
Returns true
if an additional description given?.
34 35 36 |
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 34 def described? described_by_tag? || described_by_docstring? end |
#mentioned? ⇒ Boolean
Returns true
if the parameter is mentioned in the docs.
39 40 41 |
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 39 def mentioned? !!@tag || mentioned_by_docstring? end |
#splat? ⇒ Boolean
Returns true
if the parameter is a splat argument.
44 45 46 |
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 44 def splat? name =~ /^\*/ end |
#typed? ⇒ Boolean
Returns true
if the type of the parameter is defined.
49 50 51 |
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 49 def typed? @tag && @tag.types && !@tag.types.empty? end |
#wrongly_mentioned? ⇒ Boolean
Returns true
if the parameter is mentioned in the docs, but not present in the method’s signature.
54 55 56 |
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 54 def wrongly_mentioned? mentioned? && !@in_signature end |