Class: Inch::Language::Elixir::CodeObject::FunctionParameterObject
- Inherits:
-
Object
- Object
- Inch::Language::Elixir::CodeObject::FunctionParameterObject
- Defined in:
- lib/inch/language/elixir/code_object/function_parameter_object.rb
Overview
Proxy class for method parameters
Constant Summary collapse
- IGNORE_NAME_PREFIX =
"_"
- BAD_NAME_EXCEPTIONS =
%w(id)
- BAD_NAME_THRESHOLD =
3
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#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(attributes) ⇒ FunctionParameterObject
constructor
A new instance of FunctionParameterObject.
-
#mentioned? ⇒ Boolean
true
if the parameter is mentioned in the docs. - #name ⇒ Object (also: #fullname)
-
#splat? ⇒ Boolean
true
if the parameter is a splat argument. -
#typed? ⇒ Boolean
true
if the type of the parameter is defined. - #unnamed? ⇒ Boolean
-
#wrongly_mentioned? ⇒ Boolean
true
if the parameter is mentioned in the docs, but not present in the method’s signature.
Constructor Details
#initialize(attributes) ⇒ FunctionParameterObject
Returns a new instance of FunctionParameterObject.
7 8 9 |
# File 'lib/inch/language/elixir/code_object/function_parameter_object.rb', line 7 def initialize(attributes) @attributes = attributes end |
Instance Method Details
#[](key) ⇒ Object
11 12 13 |
# File 'lib/inch/language/elixir/code_object/function_parameter_object.rb', line 11 def [](key) @attributes[key] end |
#bad_name? ⇒ Boolean
Returns true
if the name of the parameter is uncommunicative.
21 22 23 24 |
# File 'lib/inch/language/elixir/code_object/function_parameter_object.rb', line 21 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.
27 28 29 |
# File 'lib/inch/language/elixir/code_object/function_parameter_object.rb', line 27 def block? self[:block?] end |
#described? ⇒ Boolean
Returns true
if an additional description given?.
32 33 34 |
# File 'lib/inch/language/elixir/code_object/function_parameter_object.rb', line 32 def described? self[:described?] || ignore? end |
#mentioned? ⇒ Boolean
Returns true
if the parameter is mentioned in the docs.
37 38 39 |
# File 'lib/inch/language/elixir/code_object/function_parameter_object.rb', line 37 def mentioned? self[:mentioned?] || ignore? end |
#name ⇒ Object Also known as: fullname
41 42 43 |
# File 'lib/inch/language/elixir/code_object/function_parameter_object.rb', line 41 def name self[:name] end |
#splat? ⇒ Boolean
Returns true
if the parameter is a splat argument.
47 48 49 |
# File 'lib/inch/language/elixir/code_object/function_parameter_object.rb', line 47 def splat? self[:splat?] end |
#typed? ⇒ Boolean
Returns true
if the type of the parameter is defined.
52 53 54 |
# File 'lib/inch/language/elixir/code_object/function_parameter_object.rb', line 52 def typed? self[:typed?] || ignore? end |
#unnamed? ⇒ Boolean
56 57 58 |
# File 'lib/inch/language/elixir/code_object/function_parameter_object.rb', line 56 def unnamed? name == '' end |
#wrongly_mentioned? ⇒ Boolean
Returns true
if the parameter is mentioned in the docs, but not present in the method’s signature.
62 63 64 |
# File 'lib/inch/language/elixir/code_object/function_parameter_object.rb', line 62 def wrongly_mentioned? self[:wrongly_mentioned?] end |