This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define :create_ruleset do |n| | |
rules = Hash.new | |
return rules if n > 255 | |
binary = "%08b" % n | |
8.times do |i| | |
key = "%03b" % i | |
rules[key] = binary[7-i].to_i | |
end | |
return rules | |
end |