Sha256: 00180d8f581de0b55b052045a0bf9342d216700a7668fa791954e8a95191969e

Contents?: true

Size: 631 Bytes

Versions: 3

Compression:

Stored size: 631 Bytes

Contents

require "csv"

format :csv do
  def show view, args
    view ||= :titled
    super view, args
  end

  def nests
    [["_self", { view: :name }], ["_self", { view: :type }]]
  end

  def default_nest_view
    :titled
  end

  def default_item_view
    :name
  end

  view :titled do
    voo.items[:view] ||= :row
    (render_header + render_body).map { |row| CSV.generate_line row }.join
  end

  view :body do
    item_cards.map { |item_card| nest item_card }
  end

  view :row do
    nests.map { |nest_args| nest(*nest_args) }
  end

  # localize
  view :header do
    [%w[Name Type]]
  end

  view :unknown do
    ""
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
card-mod-format-0.18.1 set/all/csv.rb
card-mod-format-0.18.0 set/all/csv.rb
card-mod-format-0.17.0 set/all/csv.rb