Sha256: 3882911af770efb7db04cc2b48d9146afed4b413f435fe5292bcc6ae56cf477a

Contents?: true

Size: 730 Bytes

Versions: 2

Compression:

Stored size: 730 Bytes

Contents

# frozen_string_literal: true

module Rows::Utils

# formatting
  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

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rows_controller-3.0.0 lib/rows/utils.rb
rows_controller-2.2.2 lib/rows/utils.rb