class HammerCLI::Output::Adapter::CSValues

Public Class Methods

new(context = {}, formatters = {}, filters = {}) click to toggle source
# File lib/hammer_cli/output/adapter/csv.rb, line 129
def initialize(context = {}, formatters = {}, filters = {})
  super
  @paginate_by_default = false
end

Public Instance Methods

features() click to toggle source
# File lib/hammer_cli/output/adapter/csv.rb, line 134
def features
  return %i[serialized inline] if tags.empty?

  tags.map { |t| HammerCLI::Output::Utils.tag_to_feature(t) }
end
print_collection(fields, collection) click to toggle source
print_message(msg, msg_params={}) click to toggle source
print_record(fields, record) click to toggle source
row_data(fields, collection) click to toggle source
# File lib/hammer_cli/output/adapter/csv.rb, line 140
def row_data(fields, collection)
  result = []
  collection.each do |data|
    result << Cell.create_cells(FieldWrapper.wrap(fields), data, @formatters)
  end
  result
end

Private Instance Methods

default_headers(fields) click to toggle source
# File lib/hammer_cli/output/adapter/csv.rb, line 206
def default_headers(fields)
  fields.map(&:label)
end
generate(&block) click to toggle source
# File lib/hammer_cli/output/adapter/csv.rb, line 198
def generate(&block)
  CSV.generate(
    :col_sep => @context[:csv_separator] || ',',
    :encoding => 'utf-8',
    &block
  )
end