Class: Aspera::Cli::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/aspera/cli/main.rb

Overview

Global objects shared with plugins

Constant Summary collapse

MEMBERS =
%i[options transfer config formatter persistency man_header].freeze

Instance Method Summary collapse

Constructor Details

#initializenil

Initialize all members to nil, so that they are defined and can be validated later



42
43
44
# File 'lib/aspera/cli/main.rb', line 42

def initialize
  MEMBERS.each{ |i| instance_variable_set(:"@#{i}", nil)}
end

Instance Method Details

#only_manual!Symbol

Set the context to manual-only mode

Returns:

  • (Symbol)

    :only_manual



64
65
66
# File 'lib/aspera/cli/main.rb', line 64

def only_manual!
  @transfer = :only_manual
end

#only_manual?Boolean

Check if the context is in manual-only mode

Returns:

  • (Boolean)

    true if in manual-only mode



58
59
60
# File 'lib/aspera/cli/main.rb', line 58

def only_manual?
  transfer.eql?(:only_manual)
end

#validatenil

Validate that all members are set, raise exception if not

Returns:

  • (nil)

Raises:

  • (Aspera::AssertionError)

    if any member is not set



49
50
51
52
53
54
# File 'lib/aspera/cli/main.rb', line 49

def validate
  MEMBERS.each do |i|
    Aspera.assert(instance_variable_defined?(:"@#{i}"))
    Aspera.assert(!instance_variable_get(:"@#{i}").nil?)
  end
end