RubyGems Navigation menu

flex-cartesian 0.1.2

Flexible and human-friendly Cartesian product enumerator for Ruby. Supports dimension-agnostic iteration, named dimensions, structured output, lazy/eager evaluation, progress bar, JSON/YAML loading, and export to Markdown/CSV. Example: require 'flex-cartesian' # Define Cartesian space with named dimensions: example = { dim1: [1, 2], dim2: ['x', 'y'], dim3: [true, false] } s = FlexCartesian.new(example) # Iterate over all combinations and calculate function on each combination: s.cartesian { |v| puts "#{v.dim1}-#{v.dim2}" if v.dim3 } # Get number of Cartesian combinations: puts "Total size: #{s.size}" # Convert Cartesian space to array of combinations array = s.to_a(limit: 3) puts array.inspect def do_something(v) end # Display progress bar (useful for large Cartesian spaces) s.progress_each { |v| do_something(v) } # Print Cartesian space as table s.output(align: true) # Lazy evaluation without materializing entire Cartesian product in memory: s.cartesian(lazy: true).take(2).each { |v| puts v.inspect } # Load from JSON or YAML File.write('example.json', JSON.pretty_generate(example)) s = FlexCartesian.from_json('example.json') s.output # Export to Markdown s.output(format: :markdown, align: true) # Export to CSV s.output(format: :csv)

Gemfile:
=

インストール:
=

バージョン履歴:

  1. 1.2.2 July 28, 2025 (25KB)
  2. 1.2.1 July 27, 2025 (24.5KB)
  3. 1.2 July 22, 2025 (24.5KB)
  4. 1.1 July 22, 2025 (24.5KB)
  5. 1.0 July 14, 2025 (23KB)
  6. 0.1.2 July 02, 2025 (19KB)
全てのバージョンを表示(全15件)

Runtime依存関係 (4):

colorize ~> 0.8
json ~> 2.0
yaml >= 0

所有者:

プッシュ者:

作者:

  • Yury Rassokhin

SHA 256チェックサム:

=

累計ダウンロード数 1,919

このバージョンのみ 110

このバージョンがリリースされたのは:

ライセンス:

GPL-3.0

必要なRubyのバージョン: >= 0

リンク: