Class: Utils::IRB::Shell::MethodWrapper
- Inherits:
-
WrapperBase
- Object
- WrapperBase
- Utils::IRB::Shell::MethodWrapper
- Defined in:
- lib/utils/irb.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
The method reader returns the method object associated with the instance.
Attributes inherited from WrapperBase
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer
The <=> method compares the descriptions of two objects for ordering purposes.
-
#arity ⇒ Integer
The arity method returns the number of parameters expected by the method.
-
#initialize(obj, name, modul) ⇒ MethodWrapper
constructor
The initialize method sets up a new instance with the specified object, method name, and module flag.
-
#owner ⇒ Object?
The owner method retrieves the owner of the method object.
-
#source_location ⇒ Array<String, Integer>
The source_location method retrieves the file path and line number where the method is defined.
Methods inherited from WrapperBase
Constructor Details
#initialize(obj, name, modul) ⇒ MethodWrapper
The initialize method sets up a new instance with the specified object, method name, and module flag.
This method creates and configures a new instance by storing the method object and its description, handling both instance methods and regular methods based on the module flag parameter.
307 308 309 310 311 |
# File 'lib/utils/irb.rb', line 307 def initialize(obj, name, modul) super(name) @method = modul ? obj.instance_method(name) : obj.method(name) @description = @method.description(style: :namespace) end |
Instance Attribute Details
#method ⇒ Object (readonly)
The method reader returns the method object associated with the instance.
315 316 317 |
# File 'lib/utils/irb.rb', line 315 def method @method end |
Instance Method Details
#<=>(other) ⇒ Integer
The <=> method compares the descriptions of two objects for ordering purposes.
354 355 356 |
# File 'lib/utils/irb.rb', line 354 def <=>(other) @description <=> other.description end |
#arity ⇒ Integer
The arity method returns the number of parameters expected by the method.
330 331 332 |
# File 'lib/utils/irb.rb', line 330 def arity method.arity end |
#owner ⇒ Object?
The owner method retrieves the owner of the method object.
This method checks if the wrapped method object responds to the owner message and returns the owner if available, otherwise it returns nil.
323 324 325 |
# File 'lib/utils/irb.rb', line 323 def owner method.respond_to?(:owner) ? method.owner : nil end |
#source_location ⇒ Array<String, Integer>
The source_location method retrieves the file path and line number where the method is defined.
This method accesses the underlying source location information for the method object, returning an array that contains the filename and line number of the method’s definition.
343 344 345 |
# File 'lib/utils/irb.rb', line 343 def source_location method.source_location end |