module Guff class Results(R) getter :page getter :limit getter :num_rows getter :rows def initialize( @page = 1 : Int32, @limit = 1 : Int32, @num_rows = 0 : Int32, @rows = [] of R : Array(R), ) end def to_json { meta: { page: @page, limit: @limit, num_pages: (@num_rows / @limit).ceil, num_rows: @num_rows, }, rows: @rows.map { |row| row.reduce({} of String => String) do |r, k, v| r[k] = v.to_s r end }, }.to_json end end end