Sha256: 2a069bfc4125c17ee67681073f7d3afc6f78e04c80db90ca19b9dc6a5c882ce3
Contents?: true
Size: 565 Bytes
Versions: 22
Compression:
Stored size: 565 Bytes
Contents
# frozen_string_literal: true String.class_eval do # Calls `to_i` and returns the value if it is nonzero # # @return [Integer, Nil] # def to_nonzero_i val = to_i return if val.zero? val end end Numeric.class_eval do # Calls `to_i` and returns the value if it is nonzero # # @return [Integer, Nil] # def to_nonzero_i val = to_i return if val.zero? val end end NilClass.class_eval do # Calls `to_i` and returns the value if it is nonzero # # @return [Integer, Nil] # def to_nonzero_i nil end end
Version data entries
22 entries across 22 versions & 1 rubygems