Module: Ronin::CLI::MethodOptions Private
- Included in:
- StringMethodsCommand
- Defined in:
- lib/ronin/cli/method_options.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Allows adding options which call methods on a given object.
Instance Attribute Summary collapse
-
#method_calls ⇒ Array<Symbol, (Symbol, Array)>
readonly
private
The method calls to apply to an object.
Instance Method Summary collapse
-
#apply_method_options(object) ⇒ Object
private
Applies the method options to the given object.
-
#initialize(**kwargs) ⇒ Object
private
Initializes #method_calls.
Instance Attribute Details
#method_calls ⇒ Array<Symbol, (Symbol, Array)> (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.
The method calls to apply to an object.
28 29 30 |
# File 'lib/ronin/cli/method_options.rb', line 28 def method_calls @method_calls end |
Instance Method Details
#apply_method_options(object) ⇒ 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.
Applies the method options to the given object.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ronin/cli/method_options.rb', line 52 def (object) common_object_methods = Object.public_instance_methods @method_calls.each do |method,arguments,kwargs={}| allowed_methods = object.public_methods - common_object_methods unless allowed_methods.include?(method) raise(ArgumentError,"cannot call method Object##{method} on object #{object.inspect}") end object = object.public_send(method,*arguments,**kwargs) end return object end |
#initialize(**kwargs) ⇒ 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.
Initializes #method_calls.
33 34 35 36 37 |
# File 'lib/ronin/cli/method_options.rb', line 33 def initialize(**kwargs) super(**kwargs) @method_calls = [] end |