Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

(experiment) sleep method add

  • Loading branch information...
commit a3d6e647635dd94eedd43bdcc1dc87500fec8b73 1 parent 8dcec35
@matsumoto-r authored
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/mrb_random.c
View
14 src/mrb_random.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <time.h>
+#include <unistd.h>
#include "mruby.h"
#include "mruby/variable.h"
@@ -146,6 +147,18 @@ static mrb_value mrb_random_srand(mrb_state *mrb, mrb_value self)
return old_seed;
}
+mrb_value ap_mrb_sleep(mrb_state *mrb, mrb_value self)
+{
+
+ mrb_int time;
+
+ mrb_get_args(mrb, "i", &time);
+ sleep((int)time);
+
+ return self;
+}
+
+
void mrb_mruby_random_gem_init(mrb_state *mrb)
{
struct RClass *random;
@@ -154,4 +167,5 @@ void mrb_mruby_random_gem_init(mrb_state *mrb)
mrb_define_method(mrb, random, "rand", mrb_random_rand, ARGS_ANY());
mrb_define_method(mrb, random, "srand", mrb_random_srand, ARGS_ANY());
+ mrb_define_class_method(mrb, random, "sleep", ap_mrb_sleep, ARGS_ANY());
}
Please sign in to comment.
Something went wrong with that request. Please try again.