Class: Aspera::Cli::Context
- Inherits:
-
Object
- Object
- Aspera::Cli::Context
- Defined in:
- lib/aspera/cli/context.rb
Overview
Global objects shared with plugins
Constant Summary collapse
- MEMBERS =
%i[options transfer config formatter persistency man_header presets http_config].freeze
Instance Method Summary collapse
-
#initialize ⇒ nil
constructor
Initialize all members to nil, so that they are defined and can be validated later.
-
#only_manual! ⇒ Symbol
Set the context to manual-only mode.
-
#only_manual? ⇒ Boolean
Check if the context is in manual-only mode.
-
#validate ⇒ nil
Validate that all members are set, raise exception if not.
Constructor Details
#initialize ⇒ nil
Initialize all members to nil, so that they are defined and can be validated later
31 32 33 |
# File 'lib/aspera/cli/context.rb', line 31 def initialize MEMBERS.each{ |i| instance_variable_set(:"@#{i}", nil)} end |
Instance Method Details
#only_manual! ⇒ Symbol
Set the context to manual-only mode
53 54 55 |
# File 'lib/aspera/cli/context.rb', line 53 def only_manual! @transfer = :only_manual end |
#only_manual? ⇒ Boolean
Check if the context is in manual-only mode
47 48 49 |
# File 'lib/aspera/cli/context.rb', line 47 def only_manual? transfer.eql?(:only_manual) end |
#validate ⇒ nil
Validate that all members are set, raise exception if not
38 39 40 41 42 43 |
# File 'lib/aspera/cli/context.rb', line 38 def validate MEMBERS.each do |i| Aspera.assert(instance_variable_defined?(:"@#{i}")){"context member @#{i} is not defined"} Aspera.assert(!instance_variable_get(:"@#{i}").nil?){"context member @#{i} is nil"} end end |