class Reportabull::Builder

Attributes

collection[RW]
columns[RW]
options[RW]
output[RW]

Public Class Methods

new(columns, options, collection, output) click to toggle source
# File lib/reportabull/builder.rb, line 7
def initialize(columns, options, collection, output)
  @columns = columns
  @options = options
  @collection = collection
  @output = [output]
end

Public Instance Methods

build() click to toggle source
# File lib/reportabull/builder.rb, line 14
def build
  build_header
  build_rows
  output.join
end
build_header() click to toggle source
# File lib/reportabull/builder.rb, line 20
def build_header
  nil
end
build_row(resource) click to toggle source
# File lib/reportabull/builder.rb, line 30
def build_row(resource)
  columns.each_with_object({}) do |column, result|
    result[column.name] = encode(column.value(resource), options)
  end
end
build_rows() click to toggle source
# File lib/reportabull/builder.rb, line 24
def build_rows
  collection.each do |resource|
    output << build_row(resource)
  end
end
encode(content, options) click to toggle source
# File lib/reportabull/builder.rb, line 36
def encode(content, options)
  if options[:encoding]
    content.to_s.encode(options[:encoding], options[:encoding_options])
  else
    content
  end
end