Module: Usps::Support::Helpers::FlagsHelper
- Defined in:
- lib/usps/support/helpers/flags_helper.rb
Overview
Generate officer and signal flag images
Constant Summary collapse
- FLAGS_BASE_URL =
'https://flags.aws.usps.org'- SIGNAL_BASE_URL =
'https://flags.aws.usps.org/signals'
Instance Method Summary collapse
- #officer_flag(rank, format: :svg, size: nil) ⇒ Object
- #signal_flag(flag, dir: 'short', alt: nil, format: :svg) ⇒ Object
- #signal_flags(text, format: :svg) ⇒ Object
Instance Method Details
#officer_flag(rank, format: :svg, size: nil) ⇒ Object
10 11 12 13 |
# File 'lib/usps/support/helpers/flags_helper.rb', line 10 def officer_flag(rank, format: :svg, size: nil) size = ".#{size}" unless size.nil? image_tag("#{FLAGS_BASE_URL}/#{format.to_s.upcase}/#{rank}#{size}.#{format}", alt: rank) end |
#signal_flag(flag, dir: 'short', alt: nil, format: :svg) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/usps/support/helpers/flags_helper.rb', line 25 def signal_flag(flag, dir: 'short', alt: nil, format: :svg) image_tag( "#{SIGNAL_BASE_URL}/#{format.to_s.upcase}/#{dir}/#{flag}.#{format}", alt: alt || flag ) end |
#signal_flags(text, format: :svg) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/usps/support/helpers/flags_helper.rb', line 15 def signal_flags(text, format: :svg) safe_join(text.scan(/[A-Za-z0-9\s]/).map(&:downcase).split { |s| s =~ /\s/ }.map do |word| content_tag(:div, class: 'word') do safe_join(word.map do |letter| image_tag("#{SIGNAL_BASE_URL}/#{format.to_s.upcase}/short/#{letter}.#{format}", alt: letter) end) end end) end |