Class: RSpec::SleepingKingStudios::Support::MethodSignature Private
- Inherits:
-
Object
- Object
- RSpec::SleepingKingStudios::Support::MethodSignature
- Defined in:
- lib/rspec/sleeping_king_studios/support/method_signature.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
-
#max_arguments ⇒ Object
readonly
private
method initialize.
-
#min_arguments ⇒ Object
readonly
private
method initialize.
-
#optional_keywords ⇒ Object
readonly
private
method initialize.
-
#required_keywords ⇒ Object
readonly
private
method initialize.
Instance Method Summary collapse
- #any_keywords? ⇒ Boolean private
-
#block_argument? ⇒ Boolean
private
method any_keywords?.
-
#initialize(method) ⇒ MethodSignature
constructor
private
A new instance of MethodSignature.
-
#keywords ⇒ Object
private
method block_argument?.
-
#unlimited_arguments? ⇒ Boolean
private
method keywords.
Constructor Details
#initialize(method) ⇒ MethodSignature
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of MethodSignature.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature.rb', line 8 def initialize method parameters = method.parameters required = parameters.count { |type, _| :req == type } optional = parameters.count { |type, _| :opt == type } variadic = parameters.count { |type, _| :rest == type } @min_arguments = required @max_arguments = required + optional @unlimited_arguments = variadic > 0 required = parameters.select { |type, _| :keyreq == type }.map { |_, keyword| keyword } optional = parameters.select { |type, _| :key == type }.map { |_, keyword| keyword } variadic = parameters.count { |type, _| :keyrest == type } @required_keywords = required @optional_keywords = optional @any_keywords = variadic > 0 @block_argument = parameters.count { |type, _| :block == type } > 0 end |
Instance Attribute Details
#max_arguments ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
method initialize
30 31 32 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature.rb', line 30 def max_arguments @max_arguments end |
#min_arguments ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
method initialize
30 31 32 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature.rb', line 30 def min_arguments @min_arguments end |
#optional_keywords ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
method initialize
30 31 32 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature.rb', line 30 def optional_keywords @optional_keywords end |
#required_keywords ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
method initialize
30 31 32 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature.rb', line 30 def required_keywords @required_keywords end |
Instance Method Details
#any_keywords? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature.rb', line 35 def any_keywords? !!@any_keywords end |
#block_argument? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
method any_keywords?
39 40 41 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature.rb', line 39 def block_argument? !!@block_argument end |
#keywords ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
method block_argument?
43 44 45 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature.rb', line 43 def keywords @optional_keywords + @required_keywords end |
#unlimited_arguments? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
method keywords
47 48 49 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature.rb', line 47 def unlimited_arguments? !!@unlimited_arguments end |