Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to add calculated columns #66

Open
buren opened this issue Jan 4, 2021 · 0 comments
Open

Ability to add calculated columns #66

buren opened this issue Jan 4, 2021 · 0 comments

Comments

@buren
Copy link
Owner

buren commented Jan 4, 2021

Ideas 💡

Alternative 1

With argument

HoneyFormat::Matrix.new(
  data,
  calculated_columns: [[
    :full_name,
    proc { |row| "#{row.first_name} #{row.last_name}" }
  ], [
    :can_vote?,
    proc { |row| row.age }
  ]]
)

Don't like the name calculated_columns

Alternative 2

With builder

HoneyFormat::Matrix.new(data) do |builder|
  builder.add_column(
    :full_name,
    proc { |row| "#{row.first_name} #{row.last_name}" }
  )
end

If going with this we'd need to set/configure other things the same way like builder.type_map({ username: proc { |v| v.upcase } }).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant