Class: Inch::CodeObject::Proxy::MethodParameterObject

Inherits:
Object
  • Object
show all
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 Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ MethodParameterObject

Returns a new instance of MethodParameterObject.



6
7
8
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 6

def initialize(attributes)
  @attributes = attributes
end

Instance Method Details

#[](key) ⇒ Object



10
11
12
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 10

def [](key)
  @attributes[key]
end

#bad_name?Boolean

Returns true if the name of the parameter is uncommunicative.

Returns:

  • (Boolean)

    true if the name of the parameter is uncommunicative



19
20
21
22
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 19

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.

Returns:

  • (Boolean)

    true if the parameter is a block



25
26
27
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 25

def block?
  self[:block?]
end

#described?Boolean

Returns true if an additional description given?.

Returns:

  • (Boolean)

    true if an additional description given?



30
31
32
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 30

def described?
  self[:described?]
end

#mentioned?Boolean

Returns true if the parameter is mentioned in the docs.

Returns:

  • (Boolean)

    true if the parameter is mentioned in the docs



35
36
37
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 35

def mentioned?
  self[:mentioned?]
end

#nameObject Also known as: fullname



39
40
41
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 39

def name
  self[:name]
end

#splat?Boolean

Returns true if the parameter is a splat argument.

Returns:

  • (Boolean)

    true if the parameter is a splat argument



45
46
47
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 45

def splat?
  self[:splat?]
end

#typed?Boolean

Returns true if the type of the parameter is defined.

Returns:

  • (Boolean)

    true if the type of the parameter is defined



50
51
52
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 50

def typed?
  self[:typed?]
end

#wrongly_mentioned?Boolean

Returns true if the parameter is mentioned in the docs, but not present in the method’s signature.

Returns:

  • (Boolean)

    true if the parameter is mentioned in the docs, but not present in the method’s signature



56
57
58
# File 'lib/inch/code_object/proxy/method_parameter_object.rb', line 56

def wrongly_mentioned?
  self[:wrongly_mentioned?]
end