Sha256: 8a1a10c3532eee5b6d5b3a00123d3251b9a00bf529b650217968f430aa668a92
Contents?: true
Size: 490 Bytes
Versions: 27
Compression:
Stored size: 490 Bytes
Contents
class Integer # Iterates the given block, passing in increasing or decreasing values to and # including limit # # If no block is given, an Enumerator is returned instead. # # @example # 10.up_or_downto(12).to_a # => [10, 11, 12] # 10.upto(12).to_a # => [10, 11, 12] # 10.up_or_downto(8).to_a # => [10, 9, 8] # 10.downto(8).to_a # => [10, 9, 8] def up_or_downto(limit) self > limit ? self.downto(limit) : self.upto(limit) end end
Version data entries
27 entries across 27 versions & 1 rubygems