Sha256: f5680f691d32fe232c287140a242a8bd93a1ded77acb62be06975a015351e0ea
Contents?: true
Size: 778 Bytes
Versions: 6
Compression:
Stored size: 778 Bytes
Contents
# frozen_string_literal: true String.class_eval do unless method_defined?(:to_positive_i) # Calls `to_i` and returns the value if it is positive # # @return [Integer, Nil] # def to_positive_i val = to_i return unless val.positive? val end end end Numeric.class_eval do unless method_defined?(:to_positive_i) # Calls `to_i` and returns the value if it is positive # # @return [Integer, Nil] # def to_positive_i val = to_i return unless val.positive? val end end end NilClass.class_eval do unless method_defined?(:to_positive_i) # Calls `to_i` and returns the value if it is positive # # @return [Integer, Nil] # def to_positive_i nil end end end
Version data entries
6 entries across 6 versions & 1 rubygems