Module: Imgproxy::OptionsCasters::Float
- Defined in:
- lib/imgproxy/options_casters/float.rb
Overview
Casts float option
Constant Summary collapse
- ZERO_RE =
/\.0+/.freeze
Class Method Summary collapse
Class Method Details
.cast(raw) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/imgproxy/options_casters/float.rb', line 9 def self.cast(raw) raw&.to_f&.then 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 |