Sha256: 69b608508d723a97557ffcd1488330f05e9b36cf96b2622cea511d913e901018

Contents?: true

Size: 734 Bytes

Versions: 1

Compression:

Stored size: 734 Bytes

Contents

module LazyFormat
  module Rails
    module ViewHelpers
      def lazy_datetime(time)
        if time
          time.strftime("%Y-%m-%d %H:%M")
        end
      end

      def lazy_date(time)
        if time
          time.strftime("%Y-%m-%d")
        end
      end

      def lazy_percentage number, digit = 2
        if number.is_a? Numeric
          number_to_percentage(number * 100, precision: digit)
        else
          number_to_percentage(0, precision: digit)
        end
      end

      def lazy_precision number, digit = 2
        if number.is_a? Numeric
          number_with_precision(number, precision: digit)
        else
          number_with_precision(0, precision: digit)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lazy_format-0.1.0 lib/lazy_format/rails/helpers.rb