Class: Inch::CodeObject::Provider::YARD::Object::MethodParameterObject

Inherits:
Object
  • Object
show all
Defined in:
lib/inch/code_object/provider/yard/object/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

Instance Method Summary collapse

Constructor Details

#initialize(method, name, in_signature, tag) ⇒ MethodParameterObject



16
17
18
19
20
21
# File 'lib/inch/code_object/provider/yard/object/method_parameter_object.rb', line 16

def initialize(method, name, in_signature, tag)
  @method = method
  @name = name
  @tag = tag
  @in_signature = in_signature
end

Instance Attribute Details

#nameString (readonly)



8
9
10
# File 'lib/inch/code_object/provider/yard/object/method_parameter_object.rb', line 8

def name
  @name
end

Instance Method Details

#bad_name?Boolean



28
29
30
31
# File 'lib/inch/code_object/provider/yard/object/method_parameter_object.rb', line 28

def bad_name?
  return false if BAD_NAME_EXCEPTIONS.include?(name)
  name.size < BAD_NAME_THRESHOLD || name =~ /[0-9]$/
end

#block?Boolean



34
35
36
# File 'lib/inch/code_object/provider/yard/object/method_parameter_object.rb', line 34

def block?
  @in_signature.to_s =~ /^\&/
end

#described?Boolean



39
40
41
# File 'lib/inch/code_object/provider/yard/object/method_parameter_object.rb', line 39

def described?
  described_by_tag? || described_by_docstring?
end

#mentioned?Boolean



44
45
46
# File 'lib/inch/code_object/provider/yard/object/method_parameter_object.rb', line 44

def mentioned?
  !!@tag || mentioned_by_docstring?
end

#splat?Boolean



49
50
51
# File 'lib/inch/code_object/provider/yard/object/method_parameter_object.rb', line 49

def splat?
  @in_signature.to_s =~ /^\*/
end

#typed?Boolean



54
55
56
# File 'lib/inch/code_object/provider/yard/object/method_parameter_object.rb', line 54

def typed?
  @tag && @tag.types && !@tag.types.empty?
end

#wrongly_mentioned?Boolean



60
61
62
# File 'lib/inch/code_object/provider/yard/object/method_parameter_object.rb', line 60

def wrongly_mentioned?
  mentioned? && !@in_signature
end