If you invest the time earlier to create structure and process around communication, planning, and goal-setting, you can prevent missteps before they occur. The same thing happens with the data structure. And we have a solution on how to make your life easier! You can use TablePrint to structure your data.
Let’s start! TablePrint was created to show objects in formatted columns for easy reading. It lets you nest other tables of related objects, contextualizing data across tables. It’s very flexible, simple, making it easy to see the data you care about.
TablePrint tries to use sensible defaults to choose the columns to show. If you’re inspecting ActiveRecord objects, it uses the ActiveRecord column names. You can customize the output to show fewer columns or show other methods you’ve written on your model. Use symbols or strings to reference the columns.
Here are available column options that you can use:
- display_method – string/symbol/proc – used to populate the column. Can be a method name.
- formatters – array of objects – each will be called in turn as the cells are printed.
- time_format – string – passed to strftime, only affects time columns.
- width – integer – how wide you want your column.
- display_name – string – use it if you want spaces in your column name.
- separator – string – default is a vertical bar for console and markdown, change it to a comma for CSV output.
Feel free to find more examples here.
By the way, did you see our recent article about using Groupdate to group temporal data in Active Record? Oh, it’s worth reading.