Sha256: 99785ea55553fb6cd546b43635b26ae98c7ad4c70b9ba2b59d36f7e1c7ee369d

Contents?: true

Size: 1015 Bytes

Versions: 4

Compression:

Stored size: 1015 Bytes

Contents

module EuroHelper
  def nbsp
    [160].pack('U*')
  end

  def euros(number_in_euros)
    number_to_currency number_in_euros, unit: "€", separator: ",", delimiter: nbsp, format: "%n#{nbsp}%u"
  end

  def mdi_tag(name = nil, included_classes: '', size: 16,  icon: 'highlight_off', **other_named_params)
    if name.match?(/^([\w\-\_]+)( (\d\d)px)?$/) && size == 16 && icon == 'highlight_off'
      results = name.match(/^([\w\-\_]+)( (\d\d)px)?$/)
      icon = results[1]
      size = results[3].to_i if results[3].present?
    end

    included_classes += " " + other_named_params[:class] if other_named_params[:class].present?
    other_actions = other_named_params.except(:class).keys.map { |key| "#{key}=\"#{other_named_params[key]}\"" }.join(' ')

    icon = 'edit' if icon == 'stylus'
    icon = 'person_add' if icon == 'account-plus-outline'
    icon = 'earth' if icon == 'language'

    "<i class=\"material-icons md-#{size} #{name} #{included_classes}\" #{other_actions}>#{icon}</i>".html_safe
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shopapp-0.76.06 app/helpers/euro_helper.rb
shopapp-0.76.05 app/helpers/euro_helper.rb
shopapp-0.76.04 app/helpers/euro_helper.rb
shopapp-0.75.03 app/helpers/euro_helper.rb