Class: Aspera::Cli::Result::ValueList
- Inherits:
-
Result
- Object
- Result
- Aspera::Cli::Result::ValueList
- Defined in:
- lib/aspera/cli/result.rb
Overview
Value list result (Array of values with a name)
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #format(formatter) ⇒ Object
-
#initialize(data, name: 'id') ⇒ ValueList
constructor
A new instance of ValueList.
Constructor Details
#initialize(data, name: 'id') ⇒ ValueList
Returns a new instance of ValueList.
266 267 268 269 270 271 |
# File 'lib/aspera/cli/result.rb', line 266 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
#name ⇒ Object (readonly)
Returns the value of attribute name.
264 265 266 |
# File 'lib/aspera/cli/result.rb', line 264 def name @name end |
Instance Method Details
#format(formatter) ⇒ Object
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/aspera/cli/result.rb', line 273 def format(formatter) case formatter.format_type when :table, :csv formatter.display_table(@data.map{ |i| {@name => i}}, [@name]) when :text formatter.(:data, @data.join("\n")) when :ruby formatter.(:data, PP.pp(@data, +'')) when :json formatter.(:data, JSON.generate(@data)) when :jsonpp formatter.(:data, JSON.pretty_generate(@data)) when :yaml formatter.(:data, YAML.dump(@data)) else super end end |