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.
36 37 38 39 40 41 42 |
# File 'lib/usps_flags/helpers.rb', line 36 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" resize_convert(size, png_file, output_file_name) end |
.valid_flags(type = :all) ⇒ Array
Valid options for flag generation.
20 21 22 23 24 25 |
# File 'lib/usps_flags/helpers.rb', line 20 def valid_flags(type = :all) USPSFlags::Helpers::ValidFlags.load_valid_flags USPSFlags::Helpers::ValidFlags.load_special_flags USPSFlags::Helpers::ValidFlags.load_valid_flag_groups USPSFlags::Helpers::ValidFlags.valid_flags_for(type) end |