module Imgproxy::OptionsCasters::Float

Casts float option

Constants

ZERO_RE

Public Class Methods

cast(raw) click to toggle source
# File lib/imgproxy/options_casters/float.rb, line 7
def self.cast(raw)
  raw&.to_f&.yield_self do |f|
    # Convert integral value to Integer so to_s won't give us trailing zero
    i = f.to_i
    i == f ? i : f
  end
end