Class: EacCli::Runner::Context
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#program_name ⇒ Object
readonly
Returns the value of attribute program_name.
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
Instance Method Summary collapse
-
#call(method_name, *args) ⇒ Object
Call a method in the runner or in one of it ancestors.
-
#initialize(runner, *context_args) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(runner, *context_args) ⇒ Context
Returns a new instance of Context.
10 11 12 13 14 15 16 |
# File 'lib/eac_cli/runner/context.rb', line 10 def initialize(runner, *context_args) = context_args. @argv = (context_args[0] || .delete(:argv) || ARGV).dup.freeze @parent = context_args[1] || .delete(:parent) @program_name = .delete(:program_name) @runner = runner end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
8 9 10 |
# File 'lib/eac_cli/runner/context.rb', line 8 def argv @argv end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
8 9 10 |
# File 'lib/eac_cli/runner/context.rb', line 8 def parent @parent end |
#program_name ⇒ Object (readonly)
Returns the value of attribute program_name.
8 9 10 |
# File 'lib/eac_cli/runner/context.rb', line 8 def program_name @program_name end |
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
8 9 10 |
# File 'lib/eac_cli/runner/context.rb', line 8 def runner @runner end |
Instance Method Details
#call(method_name, *args) ⇒ Object
Call a method in the runner or in one of it ancestors.
19 20 21 22 23 24 |
# File 'lib/eac_cli/runner/context.rb', line 19 def call(method_name, *args) return runner.send(method_name, *args) if runner.respond_to?(method_name) return parent_call(method_name, *args) if parent.present? raise ::NameError, "No method \"#{method_name}\" found in #{runner} or in its ancestors" end |