Class: Aspera::Cli::Result::ValueList

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

Overview

Value list result (Array of values with a name)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, name: 'id') ⇒ ValueList

Returns a new instance of ValueList.



265
266
267
268
269
270
# File 'lib/aspera/cli/result.rb', line 265

def initialize(data, name: 'id')
  Aspera.assert_type(data, Array){'value list result data'}
  Aspera.assert_type(name, String){'value list name'}
  super(data: data)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



263
264
265
# File 'lib/aspera/cli/result.rb', line 263

def name
  @name
end

Instance Method Details

#format(formatter) ⇒ Object



272
273
274
275
276
277
278
279
# File 'lib/aspera/cli/result.rb', line 272

def format(formatter)
  case formatter.format_type
  when :table, :csv
    formatter.display_table(@data.map{ |i| {@name => i}}, [@name])
  else
    super
  end
end