- Timestamp:
- Jul 9, 2020, 8:51:43 AM (4 years ago)
- Location:
- EcnlProtoTool/trunk/mruby-2.1.1
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/mruby-2.1.1/mrbgems/mruby-range-ext/mrblib/range.rb
r331 r439 16 16 raise ArgumentError, "wrong number of arguments (given #{args.length}, expected 1)" unless args.length == 1 17 17 nv = args[0] 18 raise TypeError, "no implicit conversion from nil to integer" if nv.nil? 19 raise TypeError, "no implicit conversion of #{nv.class} into Integer" unless nv.respond_to?(:to_int) 20 n = nv.to_int 21 raise TypeError, "no implicit conversion of #{nv.class} into Integer" unless n.kind_of?(Integer) 18 n = nv.__to_int 22 19 raise ArgumentError, "negative array size (or size too big)" unless 0 <= n 23 20 ary = [] … … 29 26 ary 30 27 end 28 29 def max(&block) 30 val = self.first 31 last = self.last 32 return super if block 33 34 # fast path for numerics 35 if val.kind_of?(Numeric) && last.kind_of?(Numeric) 36 raise TypeError if exclude_end? && !last.kind_of?(Fixnum) 37 return nil if val > last 38 return nil if val == last && exclude_end? 39 40 max = last 41 max -= 1 if exclude_end? 42 return max 43 end 44 45 # delegate to Enumerable 46 super 47 end 48 49 def min(&block) 50 val = self.first 51 last = self.last 52 return super if block 53 54 # fast path for numerics 55 if val.kind_of?(Numeric) && last.kind_of?(Numeric) 56 return nil if val > last 57 return nil if val == last && exclude_end? 58 59 min = val 60 return min 61 end 62 63 # delegate to Enumerable 64 super 65 end 31 66 end
Note:
See TracChangeset
for help on using the changeset viewer.