Skip to content
Newer
Older
100644 60 lines (55 sloc) 982 Bytes
3ea3a08 @bovi Add documentation for Kernel
bovi authored May 2, 2012
1 ##
2 # Kernel
3 #
4 # ISO 15.3.1
e0d6430 add mruby sources
mimaki authored Apr 20, 2012
5 module Kernel
3ea3a08 @bovi Add documentation for Kernel
bovi authored May 2, 2012
6
7 ##
8 # Invoke method +print+ on STDOUT and passing +*args+
9 #
10 # ISO 15.3.1.2.10
e0d6430 add mruby sources
mimaki authored Apr 20, 2012
11 def print(*args)
12 i = 0
13 len = args.size
14 while i < len
15 __printstr__ args[i].to_s
16 i += 1
17 end
18 end
3ea3a08 @bovi Add documentation for Kernel
bovi authored May 2, 2012
19
20 ##
21 # Invoke method +puts+ on STDOUT and passing +*args*+
22 #
23 # ISO 15.3.1.2.11
e0d6430 add mruby sources
mimaki authored Apr 20, 2012
24 def puts(*args)
25 i = 0
26 len = args.size
27 while i < len
28 __printstr__ args[i].to_s
29 __printstr__ "\n"
30 i += 1
31 end
32 __printstr__ "\n" if len == 0
479df23 @matz puts should return nil; close #215
matz authored Jun 3, 2012
33 nil
e0d6430 add mruby sources
mimaki authored Apr 20, 2012
34 end
2728f30 @matz implement Kernel#p in Ruby
matz authored May 18, 2012
35
36 ##
37 # Print human readable object description
38 #
39 # ISO 15.3.1.3.34
40 def p(*args)
41 i = 0
42 len = args.size
43 while i < len
44 __printstr__ args[i].inspect
45 __printstr__ "\n"
46 i += 1
47 end
48 args[0]
49 end
e61bdbe @matz add printf method
matz authored Jun 20, 2012
50
2436ee8 @bovi Make printf optional based on sprintf
bovi authored Jun 21, 2012
51 if Kernel.respond_to?(:sprintf)
52 ##
53 # Invoke method +sprintf+ and pass +*args+ to it.
54 # Pass return value to *print* of STDOUT.
55 def printf(*args)
56 __printstr__(sprintf(*args))
57 end
e61bdbe @matz add printf method
matz authored Jun 20, 2012
58 end
e0d6430 add mruby sources
mimaki authored Apr 20, 2012
59 end
Something went wrong with that request. Please try again.