Sha256: f9dfd1f2489411807b5c188558717784a8f72596aa7f99385370b27bbf0771b8

Contents?: true

Size: 196 Bytes

Versions: 72

Compression:

Stored size: 196 Bytes

Contents

# require "eitil_core/float/safe_to_i"

class Float

  # converts a float to an integer, only when no decimal values are lost.

  def safe_to_i
    self == self.to_i ? self.to_i : self
  end

end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
eitil-2.0.8 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-2.0.7 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-2.0.6 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-2.0.5 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-2.0.4 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-2.0.3 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-2.0.2 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-2.0.1 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-2.0.0 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-1.4.1 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-1.4.0 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-1.3.12 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-1.3.11 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-1.3.10 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-1.3.9 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-1.3.8 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-1.3.7 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-1.3.6 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-1.3.5 eitil_core/lib/eitil_core/float/safe_to_i.rb
eitil-1.3.4 eitil_core/lib/eitil_core/float/safe_to_i.rb