Module: Remise::ApplicationHelper

Defined in:
app/helpers/remise/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#leading_emoji(label) ⇒ Object



3
4
5
# File 'app/helpers/remise/application_helper.rb', line 3

def leading_emoji(label)
  label[/^\p{Emoji}/u]
end

#prefer_formatted(h) ⇒ Object

Given a config like url: { value: "https://...", formatted: "short.form/path" } This method gets the formatted-value: prefer_formatted(config) #=> "short.form/path" Also works for url: "one value".



16
17
18
19
20
# File 'app/helpers/remise/application_helper.rb', line 16

def prefer_formatted(h)
  return h[:formatted] if h.is_a?(Hash) && h.has_key?(:formatted)
  return h[:value] if h.is_a?(Hash)
  h
end

#prefer_value(h) ⇒ Object

Given a config like url: { value: "https://...", formatted: "short.form/path" } This method gets the value: prefer_value(config) #=> "https://..." Also works for url: "one value".



27
28
29
30
# File 'app/helpers/remise/application_helper.rb', line 27

def prefer_value(h)
  return h[:value] if h.is_a?(Hash) && h.has_key?(:value)
  h
end

#strip_leading_emoji(label) ⇒ Object



7
8
9
# File 'app/helpers/remise/application_helper.rb', line 7

def strip_leading_emoji(label)
  label.sub(/^\p{Emoji}/u, "")
end