def all
      rules = []

      raw.each do |type, details|
        # Add general rules
        Array(details['prefix']).each do |prefix|
          rules.push({
            prefix: prefix.to_s,
            length: details['length'],
            type:   type
          })
        end

        # Process each country
        Array(details['countries']).each do |country, prefixes|
          # Add a rule for each prefix
          Array(prefixes).each do |prefix|
            rules.push({
              prefix: prefix.to_s,
              length: details['length'],
              type:   type,
              country: country,
            })
          end
        end

      end

      # Sort by prefix length
      rules.sort { |x, y|  y[:prefix].length <=> x[:prefix].length }
    end
def all
      rules = []

      raw.each do |type, details|
        # Add general rules
        Array(details['prefix']).each do |prefix|
          rules.push({
            prefix: prefix.to_s,
            length: details['length'],
            type:   type
          })
        end

        # Process each country
        Array(details['countries']).each do |country, prefixes|
          # Add a rule for each prefix
          Array(prefixes).each do |prefix|
            rules.push({
              prefix: prefix.to_s,
              length: details['length'],
              type:   type,
              country: country,
            })
          end
        end

      end

      # Sort by prefix length
      rules.sort { |x, y|  y[:prefix].length <=> x[:prefix].length }
    end
Change hash format to process rules