Class: USPSFlags
- Inherits:
-
Object
- Object
- USPSFlags
- Defined in:
- lib/usps_flags.rb
Overview
Base class for the namespace. Provides a constructor DSL.
Defined Under Namespace
Classes: Config, Generate, Helpers
Class Attribute Summary collapse
-
.configuration ⇒ Object
Configuration accessor.
Instance Attribute Summary collapse
-
#field ⇒ Object
Constructor accessors.
-
#png_file ⇒ Object
Constructor accessors.
-
#scale ⇒ Object
Constructor accessors.
-
#svg_file ⇒ Object
Constructor accessors.
-
#trim ⇒ Object
Constructor accessors.
-
#type ⇒ Object
Constructor accessors.
Class Method Summary collapse
-
.configure {|configuration| ... } ⇒ Object
Configuration constructor.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ USPSFlags
constructor
Constructor for individual flags.
-
#png ⇒ String
Generates the constructed file as PNG.
-
#svg ⇒ String
Generates the constructed file as SVG.
Constructor Details
#initialize {|_self| ... } ⇒ USPSFlags
Constructor for individual flags.
104 105 106 107 108 109 110 111 112 |
# File 'lib/usps_flags.rb', line 104 def initialize @type = nil @svg_file = nil @png_file = nil @scale = nil @field = nil @trim = nil yield self if block_given? end |
Class Attribute Details
.configuration ⇒ Object
Configuration accessor.
37 38 39 |
# File 'lib/usps_flags.rb', line 37 def configuration @configuration end |
Instance Attribute Details
#field ⇒ Object
Constructor accessors.
122 123 124 |
# File 'lib/usps_flags.rb', line 122 def field @field end |
#png_file ⇒ Object
Constructor accessors.
122 123 124 |
# File 'lib/usps_flags.rb', line 122 def png_file @png_file end |
#scale ⇒ Object
Constructor accessors.
122 123 124 |
# File 'lib/usps_flags.rb', line 122 def scale @scale end |
#svg_file ⇒ Object
Constructor accessors.
122 123 124 |
# File 'lib/usps_flags.rb', line 122 def svg_file @svg_file end |
#trim ⇒ Object
Constructor accessors.
122 123 124 |
# File 'lib/usps_flags.rb', line 122 def trim @trim end |
#type ⇒ Object
Constructor accessors.
122 123 124 |
# File 'lib/usps_flags.rb', line 122 def type @type end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
Configuration constructor.
42 43 44 45 46 |
# File 'lib/usps_flags.rb', line 42 def self.configure yield(configuration) self.ensure_directories @configuration end |
Instance Method Details
#png ⇒ String
Generates the constructed file as PNG.
Requires the constructor to have a value for png_file.
137 138 139 140 141 142 143 144 |
# File 'lib/usps_flags.rb', line 137 def png raise USPSFlags::Errors::PNGGenerationError, "A path must be set with png_file." if self.png_file.nil? svg_file_storage = self.svg_file self.svg_file = "" USPSFlags::Generate.png(self.svg, outfile: self.png_file, trim: self.trim) self.svg_file = svg_file_storage self.png_file end |