diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-06-26 23:24:18 -0700 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-06-26 23:24:18 -0700 |
| commit | 2c7b9faba6ebd38def134d339be41a93f96184e8 (patch) | |
| tree | ed18376e0bcbd47606c54e1530af147b3b0cbe0b | |
| parent | 3de0a625225968faa301feabaddef96b38025e2c (diff) | |
| parent | 7f9b91517bdad2848659fd4bcaee71545e0562ea (diff) | |
| download | mruby-2c7b9faba6ebd38def134d339be41a93f96184e8.tar.gz mruby-2c7b9faba6ebd38def134d339be41a93f96184e8.zip | |
Merge pull request #332 from bovi/printf-not-implemented
Sprintf NotImplementedError
| -rw-r--r-- | mrblib/print.rb | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/mrblib/print.rb b/mrblib/print.rb index 7ec6d70ef..3ebd77ee6 100644 --- a/mrblib/print.rb +++ b/mrblib/print.rb @@ -48,12 +48,24 @@ module Kernel args[0] end - if Kernel.respond_to?(:sprintf) - ## - # Invoke method +sprintf+ and pass +*args+ to it. - # Pass return value to *print* of STDOUT. - def printf(*args) + ## + # Invoke method +sprintf+ and pass +*args+ to it. + # Pass return value to +print+ of STDOUT. + def printf(*args) + if Kernel.respond_to?(:sprintf) __printstr__(sprintf(*args)) + else + raise NotImplementedError.new('sprintf not available') + end + end + + ## + # +sprintf+ is defined in +src/sprintf.c+ + # This stub method is only to inform the user + # that +sprintf+ isn't implemented. + unless Kernel.respond_to?(:sprintf) + def sprintf(*args) + raise NotImplementedError.new('sprintf not available') end end end |
