#!/usr/bin/ruby

#
## https://rosettacode.org/wiki/General_FizzBuzz
#

class FizzBuzz(schema=Hash.new(<3 Fizz 5 Buzz>...)) {
    method filter(this) {
        var fb = '';
        schema.sort_by {|k,_| k.to_i }.each { |pair|
            fb += (this %% pair[0].to_n ? pair[1] : '');
        }
        fb.len > 0 ? fb : this;
    }
}

func GeneralFizzBuzz(upto, schema) {
    var ping = FizzBuzz();
    defined(schema) && (
        ping.schema = schema.to_hash;
    );
    upto.of {|i| ping.filter(i+1) };
}

GeneralFizzBuzz(20, <3 Fizz 5 Buzz 7 Baxx>).each { .say };