Commit 94e9d049 authored by James Edwards-Jones's avatar James Edwards-Jones

Added RDoc to CsvBuilder

parent e7568213
# Generates CSV when given a mapping and a collection.
#
# Takes a hash of 'Column Heading' => 'value_method'.
#
# The value method will be called once for each object in the collection, to
# determine the value for that row. It can either be the name of a method on
# the object, or a lamda to call passing in the object.
#
# Example:
#
# columns = {
# 'Title' => 'title',
# 'Comment' => 'comment',
# 'Author' => -> (post) { post.author.full_name }
# 'Created At (UTC)' => -> (post) { post.created_at&.strftime('%Y-%m-%d %H:%M:%S') }
# }
#
# CsvBuilder.new(columns).render(@posts)
#
class CsvBuilder
def initialize(header_to_value_hash)
@header_to_value_hash = header_to_value_hash
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment