lib/usps_flags/generate.rb in usps_flags-0.1.18 vs lib/usps_flags/generate.rb in usps_flags-0.1.19

- old
+ new

@@ -6,11 +6,11 @@ # @param [String] outfile The path to save the SVG file to. If not set, prints to console. # @param [Boolean] field Whether to generate the flag field (including any border). # @param [String] scale The image scale divisor factor. # @return [String] Returns the SVG data. def self.get(flag, outfile: nil, scale: nil, field: true) - flag = flag.upcase + flag = flag.upcase.gsub("/", "").gsub("_", "").gsub("PENNANT", "") if ["CRUISE", "OIC"].include?(flag) self.pennant(type: flag, outfile: outfile, scale: scale) elsif flag.upcase == "ENSIGN" self.ensign(outfile: outfile, scale: scale) elsif flag.upcase == "US" @@ -217,11 +217,11 @@ # @param [String] scale The image scale divisor factor. # @return [String] Returns the SVG data. def self.spec(outfile: nil, fly: nil, unit: nil, scale: nil) fly = fly.nil? ? USPSFlags::Config::BASE_FLY : fly final_svg = "" - final_svg << USPSFlags::Core.headers(scale: scale) + final_svg << USPSFlags::Core.headers(scale: scale, title: "USPS Trident Specifications") final_svg << USPSFlags::Core.trident_spec(fly: fly, unit: unit) final_svg << USPSFlags::Core.footer if outfile.nil? puts final_svg, "\n" @@ -236,11 +236,11 @@ private def self.flag(rank: nil, width: USPSFlags::Config::BASE_FLY, outfile: nil, scale: nil, field: true) raise "Error: No rank specified." if rank.nil? final_svg = "" - final_svg << USPSFlags::Core.headers(scale: scale) + final_svg << USPSFlags::Core.headers(scale: scale, title: rank) rank.slice!(0) if !field && rank[0].upcase == "P" && rank != "PORTCAP" rank = "CDR" if rank == "C" case rank.upcase @@ -473,11 +473,17 @@ final_svg end def self.pennant(type: "cruise", outfile: nil, scale: nil) final_svg = "" - final_svg << USPSFlags::Core.headers(pennant: true, scale: scale) + title = case type.upcase + when "CRUISE" + "Cruise Pennant" + when "OIC" + "Officer-in-Charge Pennant" + end + final_svg << USPSFlags::Core.headers(pennant: true, scale: scale, title: title) final_svg << USPSFlags::Core.pennant(type) final_svg << USPSFlags::Core.footer if outfile.nil? puts final_svg, "\n" @@ -489,11 +495,11 @@ final_svg end def self.ensign(outfile: nil, scale: nil) final_svg = "" - final_svg << USPSFlags::Core.headers(scale: scale) + final_svg << USPSFlags::Core.headers(scale: scale, title: "USPS Ensign") final_svg << USPSFlags::Core.ensign final_svg << USPSFlags::Core.footer if outfile.nil? puts final_svg, "\n" @@ -507,11 +513,11 @@ def self.wheel(outfile: nil, scale: nil) width = 4327.4667 height = 4286.9333 final_svg = "" - final_svg << USPSFlags::Core.headers(width: width, height: height, scale: scale) + final_svg << USPSFlags::Core.headers(width: width, height: height, scale: scale, title: "USPS Ensign Wheel") final_svg << USPSFlags::Core.wheel final_svg << USPSFlags::Core.footer if outfile.nil? puts final_svg, "\n" @@ -527,10 +533,10 @@ base_hoist = 2000.to_f base_fly = base_hoist * 1.91 hoist = scale.nil? ? base_hoist : (base_hoist / scale) fly = hoist * 1.91 final_svg = "" - final_svg << USPSFlags::Core.headers(width: fly, height: hoist, scale: scale) + final_svg << USPSFlags::Core.headers(width: fly, height: hoist, scale: scale, title: "US Ensign") final_svg << USPSFlags::Core.us final_svg << USPSFlags::Core.footer if outfile.nil? puts final_svg, "\n"