Class: Float
- Defined in:
- ext/enterprise_script_service/mruby/src/numeric.c,
ext/enterprise_script_service/mruby/mrblib/numeric.rb,
ext/enterprise_script_service/mruby-mpdecimal/mrblib/mpdecimal.rb
Overview
******************************************************************
<code>Float</code> objects represent inexact real numbers using
the native architecture's double-precision floating point
representation.
Instance Method Summary collapse
Instance Method Details
#step(num = nil, step = 1, &block) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'ext/enterprise_script_service/mruby/mrblib/numeric.rb', line 163 def step(num=nil, step=1, &block) raise ArgumentError, "step can't be 0" if step == 0 return to_enum(:step, num, step) unless block i = self if num == self || step.infinite? block.call(i) if step > 0 && i <= (num||i) || step < 0 && i >= (num||-i) elsif num == nil while true block.call(i) i += step end elsif step > 0 while i <= num block.call(i) i += step end else while i >= num block.call(i) i += step end end self end |