Class: USPSFlags::Burgees
- Inherits:
-
Object
- Object
- USPSFlags::Burgees
- Defined in:
- lib/usps_flags/burgees.rb
Overview
Main class for generating burgees.
Instance Attribute Summary collapse
-
#outfile ⇒ Object
Returns the value of attribute outfile.
-
#squadron ⇒ Object
Returns the value of attribute squadron.
-
#title ⇒ Object
writeonly
attr_accessor :width attr_accessor :height.
Class Method Summary collapse
-
.available ⇒ Object
List of available burgees.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Burgees
constructor
Constructor for generating burgees.
-
#svg ⇒ String
Generates the constructed file as SVG.
Constructor Details
#initialize {|_self| ... } ⇒ Burgees
Constructor for generating burgees.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/usps_flags/burgees.rb', line 24 def initialize @squadron = nil @outfile = nil # @width = 3000 # @height = 2000 @title = nil @generated_at = Time.now.strftime("%Y%m%d.%H%S%z") yield self if block_given? @title ||= title(@squadron) end |
Instance Attribute Details
#outfile ⇒ Object
Returns the value of attribute outfile.
36 37 38 |
# File 'lib/usps_flags/burgees.rb', line 36 def outfile @outfile end |
#squadron ⇒ Object
Returns the value of attribute squadron.
35 36 37 |
# File 'lib/usps_flags/burgees.rb', line 35 def squadron @squadron end |
#title=(value) ⇒ Object
attr_accessor :width attr_accessor :height
39 40 41 |
# File 'lib/usps_flags/burgees.rb', line 39 def title=(value) @title = value end |
Class Method Details
.available ⇒ Object
List of available burgees.
11 12 13 |
# File 'lib/usps_flags/burgees.rb', line 11 def self.available (USPSFlags::Burgees::Builtins.available + USPSFlags::Burgees::Customs.available).uniq end |
Instance Method Details
#svg ⇒ String
Generates the constructed file as SVG.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/usps_flags/burgees.rb', line 45 def svg raise USPSFlags::Errors::UnknownBurgee unless USPSFlags::Burgees.available.include?(@squadron) @svg = " \#{USPSFlags::Core.headers(title: @title)}\n \#{core(@squadron)}\n \#{USPSFlags::Core.footer}\n SVG\n\n USPSFlags::Helpers.output(@svg, outfile: @outfile)\nend\n" |