Sha256: 914c748263998d37a6b0dafbcaa104a36953fc7ad3898a845d84a9478901be55

Contents?: true

Size: 775 Bytes

Versions: 2

Compression:

Stored size: 775 Bytes

Contents

module Dither

  def self.all_pairs(params, t = 2, opts = {})
    constraints = constraints_to_java(params.length, opts[:constraints])
    com.github.jesg.dither.Dither.ipog(
      t.to_java(:int),
      params.map(&:to_java).to_java,
      constraints).to_a
  rescue com.github.jesg.dither.DitherError => e
    raise Dither::Error.new(e.message)
  end

  private

  def self.constraints_to_java(param_length, constraints)
    return [].to_java if constraints.nil?
    result = []
    constraints.each do |constraint|
      new_constraint = Array.new(param_length)
      constraint.each do |k, v|
        new_constraint[k] = v
        puts "#{k} => #{v}"
      end
      result << new_constraint
    end
    result.map { |a| a.to_java(java.lang.Integer) }.to_java
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dither-0.0.8-java lib/dither/java_ext/dither.rb
dither-0.0.8 lib/dither/java_ext/dither.rb