Permalink
Browse files

raise NoImplementedError also for sprintf in case it isn't available

  • Loading branch information...
1 parent e841135 commit 7f9b91517bdad2848659fd4bcaee71545e0562ea @bovi bovi committed Jun 27, 2012
Showing with 11 additions and 1 deletion.
  1. +11 −1 mrblib/print.rb
View
@@ -50,12 +50,22 @@ def p(*args)
##
# Invoke method +sprintf+ and pass +*args+ to it.
- # Pass return value to *print* of STDOUT.
+ # 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

0 comments on commit 7f9b915

Please sign in to comment.