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
7 8 9 10 11 12 13 |
# 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 |