Class: Rubyzen::Declarations::MethodDeclaration
- Inherits:
-
Object
- Object
- Rubyzen::Declarations::MethodDeclaration
- Includes:
- Providers::BlocksProvider, Providers::CallSiteProvider, Providers::ClassNameProvider, Providers::ConstantsProvider, Providers::FilePathProvider, Providers::IfStatementsProvider, Providers::LineNumberProvider, Providers::LinesOfCodeProvider, Providers::RaisesProvider, Providers::RescuesProvider, 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::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.
32 33 34 35 |
# File 'lib/rubyzen/declarations/method_declaration.rb', line 32 def initialize(node, parent_class) @node = node @parent_class = parent_class end |
Instance Attribute Details
#node ⇒ RuboCop::AST::Node (readonly)
26 27 28 |
# File 'lib/rubyzen/declarations/method_declaration.rb', line 26 def node @node end |
#parent_class ⇒ ClassDeclaration, ModuleDeclaration (readonly) Also known as: parent
29 30 31 |
# File 'lib/rubyzen/declarations/method_declaration.rb', line 29 def parent_class @parent_class end |
Instance Method Details
#name ⇒ String
Returns the method name.
40 41 42 |
# File 'lib/rubyzen/declarations/method_declaration.rb', line 40 def name node.method_name.to_s end |
#parameters ⇒ Collections::ParametersCollection
Returns the method’s parameters.
47 48 49 50 51 52 53 |
# File 'lib/rubyzen/declarations/method_declaration.rb', line 47 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.
58 59 60 |
# File 'lib/rubyzen/declarations/method_declaration.rb', line 58 def parameters? node.arguments.any? end |