In Files

  • mrblib/numeric.rb

Integer

Integer

ISO 15.2.8

Public Instance Methods

ceil() click to toggle source

Returns the receiver simply.

ISO 15.2.8.3.14

 
               # File mrblib/numeric.rb, line 11
def ceil
  self
end
            
downto(num, &block) click to toggle source

Calls the given block once for each Integer from self downto num.

ISO 15.2.8.3.15

 
               # File mrblib/numeric.rb, line 20
def downto(num, &block)
  i = self
  while(i >= num)
    block.call(i)
    i -= 1
  end
  self
end
            
floor() click to toggle source

Returns the receiver simply.

ISO 15.2.8.3.17

 
               # File mrblib/numeric.rb, line 33
def floor
  self
end
            
round() click to toggle source

Returns the receiver simply.

ISO 15.2.8.3.24

 
               # File mrblib/numeric.rb, line 54
def round
  self
end
            
step(num, step=1, &block) click to toggle source

Calls the given block from self to num incremented by step (default 1).

 
               # File mrblib/numeric.rb, line 84
def step(num, step=1, &block)
  i = if num.kind_of? Float then self.to_f else self end
  while(i <= num)
    block.call(i)
    i += step
  end
  self
end
            
times(&block) click to toggle source

Calls the given block self times.

ISO 15.2.8.3.22

 
               # File mrblib/numeric.rb, line 41
def times(&block)
  i = 0
  while(i < self)
    block.call(i)
    i += 1
  end
  self
end
            
truncate() click to toggle source

Returns the receiver simply.

ISO 15.2.8.3.26

 
               # File mrblib/numeric.rb, line 62
def truncate
  self
end
            
upto(num, &block) click to toggle source

Calls the given block once for each Integer from self upto num.

ISO 15.2.8.3.27

 
               # File mrblib/numeric.rb, line 71
def upto(num, &block)
  i = self
  while(i <= num)
    block.call(i)
    i += 1
  end
  self
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.

blog comments powered by Disqus