lib/usps_flags/burgees.rb in usps_flags-burgees-0.0.18 vs lib/usps_flags/burgees.rb in usps_flags-burgees-0.0.19
- old
+ new
@@ -4,10 +4,11 @@
# Main class for generating burgees.
class USPSFlags::Burgees
require 'usps_flags/burgees/builtins'
require 'usps_flags/burgees/customs'
+ require 'usps_flags/burgees/crossed'
# List of available burgees.
def self.available
(USPSFlags::Burgees::Builtins.available + USPSFlags::Burgees::Customs.available).uniq
end
@@ -39,29 +40,43 @@
attr_accessor :title
attr_accessor :outfile
# Generates the constructed file as SVG.
#
+ # @params crossed Returns the burgee crossed-staves with the Ensign.
# @return [String] Returns the SVG file output path, or the svg data if no path was specified.
- def svg
+ def svg(crossed: false)
raise USPSFlags::Errors::UnknownBurgee unless USPSFlags::Burgees.available.include?(@squadron)
+ if crossed
+ burgee = crossed(@squadron)
+ header_opts = { width: 1200, height: 600, scale: 7.25 }
+ else
+ burgee = core(@squadron)
+ header_opts = {}
+ end
+
@svg = <<~SVG
- #{USPSFlags::Core.headers(title: @title)}
- #{core(@squadron)}
+ #{USPSFlags::Core.headers(header_opts.merge(title: @title))}
+ #{burgee}
#{USPSFlags::Core.footer}
SVG
USPSFlags::Helpers.output(@svg, outfile: @outfile)
end
private
+
def core(burgee)
if custom?(burgee)
USPSFlags::Burgees::Customs.get(burgee)
elsif builtin?(burgee)
USPSFlags::Burgees::Builtins.get(burgee)
end
+ end
+
+ def crossed(burgee)
+ USPSFlags::Burgees::Crossed.generate(core(burgee))
end
def custom?(burgee)
USPSFlags::Burgees::Customs.available.include?(burgee)
end