diff options
| author | Ryan Lopopolo <[email protected]> | 2019-07-09 01:40:44 -0700 |
|---|---|---|
| committer | Ryan Lopopolo <[email protected]> | 2019-07-09 01:40:44 -0700 |
| commit | d9c530379343ef0dd0f314c982ddeedea8eb1a60 (patch) | |
| tree | 562d843ee7350e73464e2dd941d9a19836f1d6d4 /mrblib | |
| parent | 4085709ae1736fb755955d3d52b6b73c15853506 (diff) | |
| download | mruby-d9c530379343ef0dd0f314c982ddeedea8eb1a60.tar.gz mruby-d9c530379343ef0dd0f314c982ddeedea8eb1a60.zip | |
Remove attempt at spec-compliant Range#max and Range#min from core
Diffstat (limited to 'mrblib')
| -rw-r--r-- | mrblib/range.rb | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/mrblib/range.rb b/mrblib/range.rb index 746cb322c..3e6dbfb24 100644 --- a/mrblib/range.rb +++ b/mrblib/range.rb @@ -65,67 +65,4 @@ end # ISO 15.2.14.3 class Range include Enumerable - - def max(&block) - val = self.first - last = self.last - # numerics are special - if (val.kind_of?(Fixnum) || val.kind_of?(Float)) && (last.kind_of?(Fixnum) || last.kind_of?(Float)) - return nil if val > last - return nil if val == last && exclude_end? - - max = last - max -= 1 if exclude_end? - max = val if block && block.call(val, last) > 0 - return max - end - - max = nil - each do |item| - max = - if max.nil? - item - elsif block && block.call(max, item) > 0 - item - elsif item > max - item - else - max - end - end - max - end - - def min(&block) - val = self.first - last = self.last - - # numerics are special - if (val.kind_of?(Fixnum) || val.kind_of?(Float)) && (last.kind_of?(Fixnum) || last.kind_of?(Float)) - return nil if val > last - return nil if val == last && exclude_end? - - min = val - if block && block.call(val, last) > 0 - min = last - min -= 1 if exclude_end? - end - return min - end - - min = nil - each do |item| - min = - if min.nil? - item - elsif block && block.call(min, item) < 0 - item - elsif item < min - item - else - min - end - end - min - end end |
