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

Version Path
aipp-2.3.1 lib/core_ext/integer.rb
aipp-2.3.0 lib/core_ext/integer.rb
aipp-2.2.2 lib/core_ext/integer.rb
aipp-2.2.1 lib/core_ext/integer.rb
aipp-2.2.0 lib/core_ext/integer.rb
aipp-2.1.11 lib/core_ext/integer.rb
aipp-2.1.10 lib/core_ext/integer.rb
aipp-2.1.9 lib/core_ext/integer.rb
aipp-2.1.9.pre1 lib/core_ext/integer.rb
aipp-2.1.8 lib/core_ext/integer.rb
aipp-2.1.7 lib/core_ext/integer.rb
aipp-2.1.6 lib/core_ext/integer.rb
aipp-2.1.5 lib/core_ext/integer.rb
aipp-2.1.4 lib/core_ext/integer.rb
aipp-2.1.3 lib/core_ext/integer.rb
aipp-2.1.2 lib/core_ext/integer.rb
aipp-2.1.1 lib/core_ext/integer.rb
aipp-2.1.0 lib/core_ext/integer.rb
aipp-2.0.3 lib/core_ext/integer.rb
aipp-2.0.2 lib/core_ext/integer.rb