mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Move Integer.{floor,ceil,round,truncate} to mrblib/. For maintainability.
This commit is contained in:
committed by
Yukihiro "Matz" Matsumoto
parent
dd56b93639
commit
cbe7a87c68
@@ -4,6 +4,14 @@
|
||||
# ISO 15.2.8
|
||||
class Integer
|
||||
|
||||
##
|
||||
# Returns the receiver simply.
|
||||
#
|
||||
# ISO 15.2.8.3.14
|
||||
def ceil
|
||||
self
|
||||
end
|
||||
|
||||
##
|
||||
# Calls the given block once for each Integer
|
||||
# from +self+ downto +num+.
|
||||
@@ -18,6 +26,14 @@ class Integer
|
||||
self
|
||||
end
|
||||
|
||||
##
|
||||
# Returns the receiver simply.
|
||||
#
|
||||
# ISO 15.2.8.3.17
|
||||
def floor
|
||||
self
|
||||
end
|
||||
|
||||
##
|
||||
# Calls the given block +self+ times.
|
||||
#
|
||||
@@ -31,6 +47,22 @@ class Integer
|
||||
self
|
||||
end
|
||||
|
||||
##
|
||||
# Returns the receiver simply.
|
||||
#
|
||||
# ISO 15.2.8.3.24
|
||||
def round
|
||||
self
|
||||
end
|
||||
|
||||
##
|
||||
# Returns the receiver simply.
|
||||
#
|
||||
# ISO 15.2.8.3.26
|
||||
def truncate
|
||||
self
|
||||
end
|
||||
|
||||
##
|
||||
# Calls the given block once for each Integer
|
||||
# from +self+ upto +num+.
|
||||
|
||||
@@ -716,17 +716,10 @@ num_round(mrb_state *mrb, mrb_value num)
|
||||
*/
|
||||
|
||||
|
||||
/* 15.2.8.3.14 */
|
||||
/* 15.2.8.3.24 */
|
||||
/* 15.2.8.3.26 */
|
||||
/*
|
||||
* call-seq:
|
||||
* int.to_i -> integer
|
||||
* int.to_int -> integer
|
||||
* int.floor -> integer
|
||||
* int.ceil -> integer
|
||||
* int.round -> integer
|
||||
* int.truncate -> integer
|
||||
*
|
||||
* As <i>int</i> is already an <code>Integer</code>, all these
|
||||
* methods simply return the receiver.
|
||||
@@ -1430,17 +1423,13 @@ mrb_init_numeric(mrb_state *mrb)
|
||||
mrb_define_method(mrb, fixnum, "^", fix_xor, ARGS_REQ(1)); /* 15.2.8.3.11 */
|
||||
mrb_define_method(mrb, fixnum, "<<", fix_lshift, ARGS_REQ(1)); /* 15.2.8.3.12 */
|
||||
mrb_define_method(mrb, fixnum, ">>", fix_rshift, ARGS_REQ(1)); /* 15.2.8.3.13 */
|
||||
mrb_define_method(mrb, fixnum, "ceil", int_to_i, ARGS_NONE()); /* 15.2.8.3.14 */
|
||||
mrb_define_method(mrb, fixnum, "eql?", num_eql, ARGS_REQ(1)); /* 15.2.8.3.16 */
|
||||
mrb_define_method(mrb, fixnum, "floor", num_floor, ARGS_NONE()); /* 15.2.8.3.17 */
|
||||
mrb_define_method(mrb, fixnum, "hash", flo_hash, ARGS_NONE()); /* 15.2.8.3.18 */
|
||||
mrb_define_method(mrb, fixnum, "next", int_succ, ARGS_NONE()); /* 15.2.8.3.19 */
|
||||
mrb_define_method(mrb, fixnum, "round", num_round, ARGS_ANY()); /* 15.2.8.3.20 */
|
||||
mrb_define_method(mrb, fixnum, "succ", fix_succ, ARGS_NONE()); /* 15.2.8.3.21 */
|
||||
mrb_define_method(mrb, fixnum, "to_f", fix_to_f, ARGS_NONE()); /* 15.2.8.3.23 */
|
||||
mrb_define_method(mrb, fixnum, "to_s", fix_to_s, ARGS_NONE()); /* 15.2.8.3.25 */
|
||||
mrb_define_method(mrb, fixnum, "inspect", fix_to_s, ARGS_NONE());
|
||||
mrb_define_method(mrb, fixnum, "truncate", int_to_i, ARGS_NONE()); /* 15.2.8.3.26 */
|
||||
mrb_define_method(mrb, fixnum, "divmod", fix_divmod, ARGS_REQ(1)); /* 15.2.8.3.30 (x) */
|
||||
|
||||
/* Float Class */
|
||||
|
||||
Reference in New Issue
Block a user