Module: EuroHelper

Defined in:
app/helpers/euro_helper.rb

Instance Method Summary collapse

Instance Method Details

#euros(number_in_euros) ⇒ Object



6
7
8
# File 'app/helpers/euro_helper.rb', line 6

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

#mdi_tag(name = nil, included_classes: '', size: 16, icon: 'highlight_off', **other_named_params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/helpers/euro_helper.rb', line 10

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

#nbspObject



2
3
4
# File 'app/helpers/euro_helper.rb', line 2

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