Class: USPSFlags::Helpers
- Inherits:
-
Object
- Object
- USPSFlags::Helpers
- Defined in:
- lib/usps_flags/helpers.rb
Overview
Container class for helper methods.
Class Method Summary collapse
-
.resize_png(png_file, file: nil, outfile: nil, size:, size_key: nil) ⇒ Object
Resizes and saves a PNG image.
-
.valid_flags(type = :all) ⇒ Array
Valid options for flag generation.
Class Method Details
.resize_png(png_file, file: nil, outfile: nil, size:, size_key: nil) ⇒ Object
Resizes and saves a PNG image.
One of the params [file, outfile] is required, and outfile takes precedence.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/usps_flags/helpers.rb', line 30 def resize_png(png_file, file: nil, outfile: nil, size:, size_key: nil) raise USPSFlags::Errors::PNGConversionError if outfile.nil? && file.nil? raise USPSFlags::Errors::PNGConversionError if outfile.nil? && size_key.nil? output_file_name = outfile || "#{USPSFlags.configuration.flags_dir}/PNG/#{file}.#{size_key}.png" MiniMagick::Tool::Convert.new do |convert| convert << "-background" << "none" convert << "-format" << "png" convert << "-resize" << "#{size}" convert << png_file convert << output_file_name end end |
.valid_flags(type = :all) ⇒ Array
Valid options for flag generation.
16 17 18 19 |
# File 'lib/usps_flags/helpers.rb', line 16 def valid_flags(type = :all) load_valid_flags valid_flags_for(type) end |