Class: Rubyzen::Declarations::MethodDeclaration
- Inherits:
-
Object
- Object
- Rubyzen::Declarations::MethodDeclaration
- Includes:
- Providers::AssignmentsProvider, Providers::BlocksProvider, Providers::CallSiteProvider, Providers::ClassNameProvider, Providers::ConstantsProvider, Providers::FilePathProvider, Providers::IfStatementsProvider, Providers::LineNumberProvider, Providers::LinesOfCodeProvider, Providers::RaisesProvider, Providers::RescuesProvider, Providers::ReturnsProvider, Providers::VisibilityProvider
- Defined in:
- lib/rubyzen/declarations/method_declaration.rb
Overview
Represents a Ruby method definition (def or def self.).
Instance Attribute Summary collapse
- #node ⇒ RuboCop::AST::Node readonly
- #parent_class ⇒ ClassDeclaration, ModuleDeclaration (also: #parent) readonly
Instance Method Summary collapse
-
#initialize(node, parent_class) ⇒ MethodDeclaration
constructor
A new instance of MethodDeclaration.
-
#name ⇒ String
Returns the method name.
-
#parameters ⇒ Collections::ParametersCollection
Returns the method’s parameters.
-
#parameters? ⇒ Boolean
Returns whether this method has any parameters.
Methods included from Providers::AssignmentsProvider
Methods included from Providers::ReturnsProvider
Methods included from Providers::RaisesProvider
Methods included from Providers::RescuesProvider
Methods included from Providers::VisibilityProvider
#private?, #protected?, #public?, #visibility
Methods included from Providers::LinesOfCodeProvider
Methods included from Providers::CallSiteProvider
Methods included from Providers::ConstantsProvider
Methods included from Providers::LineNumberProvider
Methods included from Providers::ClassNameProvider
Methods included from Providers::FilePathProvider
Methods included from Providers::BlocksProvider
Methods included from Providers::IfStatementsProvider
Constructor Details
#initialize(node, parent_class) ⇒ MethodDeclaration
Returns a new instance of MethodDeclaration.
34 35 36 37 |
# File 'lib/rubyzen/declarations/method_declaration.rb', line 34 def initialize(node, parent_class) @node = node @parent_class = parent_class end |
Instance Attribute Details
#node ⇒ RuboCop::AST::Node (readonly)
28 29 30 |
# File 'lib/rubyzen/declarations/method_declaration.rb', line 28 def node @node end |
#parent_class ⇒ ClassDeclaration, ModuleDeclaration (readonly) Also known as: parent
31 32 33 |
# File 'lib/rubyzen/declarations/method_declaration.rb', line 31 def parent_class @parent_class end |
Instance Method Details
#name ⇒ String
Returns the method name.
42 43 44 |
# File 'lib/rubyzen/declarations/method_declaration.rb', line 42 def name node.method_name.to_s end |
#parameters ⇒ Collections::ParametersCollection
Returns the method’s parameters.
49 50 51 52 53 54 55 |
# File 'lib/rubyzen/declarations/method_declaration.rb', line 49 def parameters Collections::ParametersCollection.new( node.arguments.map do |arg| ParameterDeclaration.new(arg, self) end ) end |
#parameters? ⇒ Boolean
Returns whether this method has any parameters.
60 61 62 |
# File 'lib/rubyzen/declarations/method_declaration.rb', line 60 def parameters? node.arguments.any? end |