# Core SVG data for grade insignia.
#
# This class should never need to be called directly.
# @private
class USPSFlags::Grades::Grade
class << self
def get(grade)
return if grade.nil?
raise USPSFlags::Errors::InvalidInsignia, "Unknown grade: #{grade}" unless valid_grades.include?(grade)
send(grade)
end
def valid_grades
[:s, :p, :ap, :jn, :n, :sn]
end
def width(grade)
case grade
when :ap
USPSFlags::Config::GRADE_SPACING * 2.25 + 100
when :jn
USPSFlags::Config::GRADE_SPACING * 3 - 10
when :n
USPSFlags::Config::GRADE_SPACING * 5 + 25
end
end
private
def bar
<<~SVG
SVG
end
def star
<<~SVG
#{USPSFlags::Core::Star.new.svg.gsub("fill=\"#FFFFFF\"", "fill=\"#{USPSFlags::Config::GOLD}\"")}
SVG
end
def s
bar
end
def p
<<~SVG
#{bar}
#{bar}
SVG
end
def ap
<<~SVG
#{bar}
#{star}
#{bar}
SVG
end
def jn
<<~SVG
#{star}
#{bar}
#{star}
SVG
end
def n
<<~SVG
#{star}
#{bar}
#{star}
#{bar}
#{star}
SVG
end
def sn
box_width = USPSFlags::Grades::Grade.width(:n) + 85
<<~SVG
#{n}
SVG
end
end
end