Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rubypivot

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rubypivot

  • 0.0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Rubypivot

Rubypivot is a tool to make pivot table arrays for ruby. It transforming a dataset or array of hashes into a spreadsheet-style array.

Suggestions and pull requests are welcome.

Installation

gem install rubypivot

Usage

Pivot class transform database record type array into pivot table Hash or Array

require "rubypivot"
pivot = Rubypivot::Pivot.new(source_data, :month, :name, :value, data_type: :integer)
pivot_array = pivot.build
pivot_array.each do |line|
  p line
end

SpreadTable class makes a Hash table from pivot hash, which makes it easy to build HTML table with totals, layouts, colors.

require "rubypivot"
pivot = Rubypivot::Pivot.new(source_data, :month, :name, :value, data_type: :integer)
pivot_hash = pivot.build_hash
spread = Rubypivot::SpreadTable.new(pivot_hash, data_type: :integer)
spread.rows.each do |row|
  puts row.to_s
end
require "rubypivot"
spread = Rubypivot::SpreadTable.new(DATA_SOURCE, data_type: :integer)
puts spread.to_html(class: "table table-striped", line_end: :cr)

SpreadTable

See sample scripts in examples folder.

Supported data aggregation is only SUM for numeric values.

Total calculation supported.

To do-s

  • Bootstrap Grid output

History

  • Ver. 0.0.2 : 2021-01-01 New class SpreadTable supports to_s, to_html (HTML table), to_grid (Bootstrap grid)
  • Ver. 0.0.1 : 2020-12-28 First release. Making pivot array

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 01 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc