Module: Quandl::Command::Task::Presentation

Extended by:
ActiveSupport::Concern
Included in:
Quandl::Command::Task
Defined in:
lib/quandl/command/task/presentation.rb

Instance Method Summary collapse

Instance Method Details

#present(object, opts = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/quandl/command/task/presentation.rb', line 9

def present(object, opts={})
  opts = opts.symbolize_keys!
  opts.reverse_merge!(options.to_h) if options.to_h.present?
  presenters = Quandl::Command::Presenter.new( object, opts )
  # format order of importance
  format = get_output_format( opts )
  # convert each object to_format and write to stdout
  presenters.each do |presenter|
    # write requested format to stdout
    info( presenter.to_format(format) )
    # write errors to stderr
    error( presenter.to_stderr ) unless presenter.valid?
  end
end