Last change
on this file since 270 was 270, checked in by coas-nagasima, 7 years ago |
mruby版ECNLプロトタイピング・ツールを追加
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-ruby
|
File size:
1.1 KB
|
Rev | Line | |
---|
[270] | 1 | ##
|
---|
| 2 | # Kernel
|
---|
| 3 | #
|
---|
| 4 | # ISO 15.3.1
|
---|
| 5 | module Kernel
|
---|
| 6 | ##
|
---|
| 7 | # Invoke method +print+ on STDOUT and passing +*args+
|
---|
| 8 | #
|
---|
| 9 | # ISO 15.3.1.2.10
|
---|
| 10 | def print(*args)
|
---|
| 11 | i = 0
|
---|
| 12 | len = args.size
|
---|
| 13 | while i < len
|
---|
| 14 | __printstr__ args[i].to_s
|
---|
| 15 | i += 1
|
---|
| 16 | end
|
---|
| 17 | end
|
---|
| 18 |
|
---|
| 19 | ##
|
---|
| 20 | # Invoke method +puts+ on STDOUT and passing +*args*+
|
---|
| 21 | #
|
---|
| 22 | # ISO 15.3.1.2.11
|
---|
| 23 | def puts(*args)
|
---|
| 24 | i = 0
|
---|
| 25 | len = args.size
|
---|
| 26 | while i < len
|
---|
| 27 | s = args[i].to_s
|
---|
| 28 | __printstr__ s
|
---|
| 29 | __printstr__ "\n" if (s[-1] != "\n")
|
---|
| 30 | i += 1
|
---|
| 31 | end
|
---|
| 32 | __printstr__ "\n" if len == 0
|
---|
| 33 | nil
|
---|
| 34 | end
|
---|
| 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
|
---|
| 50 |
|
---|
| 51 | unless Kernel.respond_to?(:sprintf)
|
---|
| 52 | def printf(*args)
|
---|
| 53 | raise NotImplementedError.new('printf not available')
|
---|
| 54 | end
|
---|
| 55 | def sprintf(*args)
|
---|
| 56 | raise NotImplementedError.new('sprintf not available')
|
---|
| 57 | end
|
---|
| 58 | else
|
---|
| 59 | def printf(*args)
|
---|
| 60 | __printstr__(sprintf(*args))
|
---|
| 61 | nil
|
---|
| 62 | end
|
---|
| 63 | end
|
---|
| 64 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.