Module: AuthcanEasyrollerHelper

Defined in:
lib/helpers/authcan_easyroller.rb

Instance Method Summary collapse

Instance Method Details

#datify(object, format = :long) ⇒ Object



10
11
12
# File 'lib/helpers/authcan_easyroller.rb', line 10

def datify(object, format = :long)
  object.to_s(format) unless object.nil?
end

#form_descriptor(message = nil) ⇒ Object



29
30
31
# File 'lib/helpers/authcan_easyroller.rb', line 29

def form_descriptor(message = nil)
  raw "<br /><span class='form-descriptor-element'>#{message}</span>"
end


33
34
35
# File 'lib/helpers/authcan_easyroller.rb', line 33

def link_separator
  raw "&nbsp;|&nbsp;"
end

#namify(object) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/helpers/authcan_easyroller.rb', line 2

def namify(object)
  if object.present? and object.respond_to? :name
    object.send(:name)
  else
    ""
  end
end

#phonify(object) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/helpers/authcan_easyroller.rb', line 14

def phonify(object)
  if object.respond_to? :gsub
    s = object.gsub(/[^0-9]/, '')
 
    case s.length
      when 11 then "#{s[0..0]} (#{s[1..3]}) #{s[4..6]}-#{s[7..10]}"
      when 10 then "(#{s[0..2]}) #{s[3..5]}-#{s[6..9]}"
      when 7 then "#{s[0..2]}-#{s[3..6]}"
      else s
    end
  else
    object.to_s
  end
end