Sha256: 5f79e9e11b88f2b6aec67103fa9b095cea94c0c702cfdf7d8a71d4028d535c92
Contents?: true
Size: 753 Bytes
Versions: 6
Compression:
Stored size: 753 Bytes
Contents
# frozen_string_literal: true String.class_eval do unless method_defined?(:to_nonzero_i) # 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 end Numeric.class_eval do unless method_defined?(:to_nonzero_i) # 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 end NilClass.class_eval do unless method_defined?(:to_nonzero_i) # Calls `to_i` and returns the value if it is nonzero # # @return [Integer, Nil] # def to_nonzero_i nil end end end
Version data entries
6 entries across 6 versions & 1 rubygems