# frozen_string_literal: true # Core SVG data for merit marks. # # This class should never need to be called directly. # @private class USPSFlags::Grades::MeritMarks class << self def get(number) return if number < 1 svg = +'' new_lines = 0 top_row = number % 20 svg << generate_top_row(top_row) number -= top_row number, new_lines, svg = add_row(number, new_lines, svg) while number > 0 new_lines.times { svg << '' } svg end private def add_row(number, new_lines, svg) number -= 20 new_lines += 1 svg << <<~SVG #{generate_full_row} SVG [number, new_lines, svg] end def bar(offset = 0) <<~SVG SVG end def generate_top_row(number) svg = +'' number.times do |i| svg << bar(45 * i) end svg end def generate_full_row svg = +'' 20.times do |i| svg << bar(45 * i) end svg end end end