Class: Aspera::Cli::Result::Special

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

Overview

Base class for special results The type is automatically derived from the class name

Direct Known Subclasses

Empty, Nothing, Null

Instance Method Summary collapse

Constructor Details

#initializeSpecial

Returns a new instance of Special.



94
95
96
97
98
# File 'lib/aspera/cli/result.rb', line 94

def initialize
  # Convert class name to symbol: Empty -> :empty, Nothing -> :nothing
  type = self.class.name.split('::').last.gsub(/([a-z])([A-Z])/, '\1_\2').downcase.to_sym
  super(data: type)
end

Instance Method Details

#format(formatter) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/aspera/cli/result.rb', line 100

def format(formatter)
  case formatter.format_type
  when :text, :nagios, :ruby, :json, :jsonpp, :yaml
    formatter.display_message(:data, @data.to_s)
  when :table, :csv
    if @data.eql?(:nothing)
      Log.log.debug('no result expected')
      return
    end
    formatter.display_message(:info, formatter.special_format(@data.to_s))
  else
    super
  end
end