Sha256: b94de0655414f9eaefd65f673c68c3fa496ed4a500f2ac37491fcedeb54cd851
Contents?: true
Size: 1013 Bytes
Versions: 4
Compression:
Stored size: 1013 Bytes
Contents
# Range `bounds` ------ Returns the first and last values of a range. ```ruby (1..9).bounds #=> [1, 9] ``` `combine` ------ Returns two concatenated ranges. ```ruby (1..3).combine(7..9) #=> [1, 2, 3, 7, 8, 9] ``` `include_with_range?` ------ Returns if a range is within another open ended range. ```ruby (1..5).include_with_range?(1) # => true (1..5).include_with_range?(2..3) # => true (1..5).include_with_range?(7) # => false (1..5).include_with_range?(2..6) # => false ``` `overlaps?` ------ Returns if two ranges overlap each other. ```ruby (1..5).overlaps?(4..6) # => true (1..5).overlaps?(7..9) # => false ``` `sample` ------ Returns a random element from the range. ```ruby (1..5).sample # => 4 ``` `shuffle(!)` ------ Returns a copy of a shuffled range of elements. ```ruby (1..5).shuffle # => [2, 5, 1, 4, 3] (1..5).shuffle! # => [3, 4, 5, 2, 1] ``` `within?` ------ Returns if one range is within another. ```ruby (1..5).within?(2..4) # => true (1..5).within?(4..6) # => false ```
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
lite-ruby-2.3.0 | docs/RANGE.md |
lite-ruby-2.2.0 | docs/RANGE.md |
lite-ruby-2.1.0 | docs/RANGE.md |
lite-ruby-2.0.7 | docs/RANGE.md |