Module: Rows::Utils

Included in:
RowsController
Defined in:
lib/rows/utils.rb

Overview

rubocop: disable all

Instance Method Summary collapse

Instance Method Details

#resource_format(x) ⇒ Object

formatting



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rows/utils.rb', line 6

def resource_format(x)
  return '--'.html_safe  if x.nil?

  bool = x.class == Time || x.class == Date || x.class == DateTime ||
         x.class == ActiveSupport::TimeWithZone
  return x.strftime('%d.%m.%Y').html_safe if bool

  # return I18n.l(x)                if bool
  # return x.to_s.html_safe         if x.class == Fixnum
  return x.to_s.html_safe         if x.is_a?(Integer)
  return 'X'.html_safe            if x.class == TrueClass
  return ' '.html_safe       if x.class == FalseClass
  return x.call                   if x.class == Proc
  return '---'.html_safe          if x.empty?

  x.to_s.gsub(/\r*\n/, '<br/>')
end