Class: Aspera::Cli::Result::Text

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

Overview

Text result

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Text

Returns a new instance of Text.

Parameters:

  • data (String, Numeric, Symbol, Boolean) —

    The value, hidden if it is a secret declared to Secret::Hider



195
196
197
198
# File 'lib/aspera/cli/result.rb', line 195

def initialize(data)
  Aspera.assert_type(data, *SCALAR_TYPES, type: ArgumentError) { 'text result data' }
  super(data: data)
end

Instance Method Details

#format(formatter) ⇒ Object



200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/aspera/cli/result.rb', line 200

def format(formatter)
  data = @data.is_a?(String) && formatter.hide_secrets? ? formatter.hide_secrets_in_string(@data) : @data
  case formatter.format_type
  when :text, :nagios
    formatter.display_message(:data, data.to_s)
  when *STRUCTURED_FORMATS
    display_structured(formatter, data)
  when :table, :csv
    formatter.display_message(:data, data)
  else
    super
  end
end