diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-03-23 08:30:03 -0700 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-03-23 08:30:03 -0700 |
| commit | 6954153fa06630aa9aaf642f8f1221cddb01793a (patch) | |
| tree | 20e4d43b0078807f58ca1e2b1a8e716fa614edac /mrblib | |
| parent | f0ac204f21661d7f1dd2fbd1e3f08a95b81d0b21 (diff) | |
| parent | b69761e28623c88f142fbff92d7b361d1129ee5f (diff) | |
| download | mruby-6954153fa06630aa9aaf642f8f1221cddb01793a.tar.gz mruby-6954153fa06630aa9aaf642f8f1221cddb01793a.zip | |
Merge pull request #1057 from mattn/mruby-print
mruby-print gem
Diffstat (limited to 'mrblib')
| -rw-r--r-- | mrblib/print.rb | 84 |
1 files changed, 11 insertions, 73 deletions
diff --git a/mrblib/print.rb b/mrblib/print.rb index 68c7837f3..1ae3ae84b 100644 --- a/mrblib/print.rb +++ b/mrblib/print.rb @@ -3,78 +3,16 @@ # # ISO 15.3.1 module Kernel - unless Kernel.respond_to?(:__printstr__) - def print(*a) - raise NotImplementedError.new('print not available') - end - def puts(*a) - raise NotImplementedError.new('puts not available') - end - def p(*a) - raise NotImplementedError.new('p not available') - end - def printf(*args) - raise NotImplementedError.new('printf not available') - end - else - unless Kernel.respond_to?(:sprintf) - def printf(*args) - raise NotImplementedError.new('printf not available') - end - def sprintf(*args) - raise NotImplementedError.new('sprintf not available') - end - end - - - ## - # Invoke method +print+ on STDOUT and passing +*args+ - # - # ISO 15.3.1.2.10 - def print(*args) - i = 0 - len = args.size - while i < len - __printstr__ args[i].to_s - i += 1 - end - end - - ## - # Invoke method +puts+ on STDOUT and passing +*args*+ - # - # ISO 15.3.1.2.11 - def puts(*args) - i = 0 - len = args.size - while i < len - s = args[i].to_s - __printstr__ s - __printstr__ "\n" if (s[-1] != "\n") - i += 1 - end - __printstr__ "\n" if len == 0 - nil - end - - ## - # Print human readable object description - # - # ISO 15.3.1.3.34 - def p(*args) - i = 0 - len = args.size - while i < len - __printstr__ args[i].inspect - __printstr__ "\n" - i += 1 - end - args[0] - end - - def printf(*args) - __printstr__(sprintf(*args)) - nil - end + def print(*a) + raise NotImplementedError.new('print not available') + end + def puts(*a) + raise NotImplementedError.new('puts not available') + end + def p(*a) + raise NotImplementedError.new('p not available') + end + def printf(*args) + raise NotImplementedError.new('printf not available') end end |
