summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-06-04 07:34:19 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-06-04 07:34:19 +0000
commitb7bc0cae539617af4dfac5b44b0ebd700efe2084 (patch)
treea65171fc36999a1cc3c537a0b8bf62ddd9b16f77 /lib
parent4cb164ee2a30ecb59ce93670e569f384c7da7521 (diff)
* string.c (rb_str_aset): should raise error if an indexing string
is not found in the receiver. * sprintf.c (rb_f_sprintf): "%d" should convert objects into integers using Integer(). * lib/tempfile.rb (Tempfile::size): added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/singleton.rb12
-rw-r--r--lib/tempfile.rb9
2 files changed, 15 insertions, 6 deletions
diff --git a/lib/singleton.rb b/lib/singleton.rb
index 6ff6d190f2..5839458577 100644
--- a/lib/singleton.rb
+++ b/lib/singleton.rb
@@ -65,7 +65,7 @@ module Singleton
# This catches ill advisted inclusions of Singleton in
# singletons types (sounds like an oxymoron) and
# helps out people counting on transitive mixins
- unless mod.instance_of? (Class)
+ unless mod.instance_of?(Class)
raise TypeError, "Inclusion of the OO-Singleton module in module #{mod}"
end
unless (class << mod; self end) <= (class << Object; self end)
@@ -73,7 +73,7 @@ module Singleton
end
super
end
- def included (klass)
+ def included(klass)
# remove build in copying methods
klass.class_eval do
define_method(:clone) {raise TypeError, "can't clone singleton #{self.type}"}
@@ -87,7 +87,7 @@ module Singleton
private :new, :allocate
# declare the self modifying klass#instance method
- define_method (:instance, Singleton::FirstInstanceCall)
+ define_method(:instance, Singleton::FirstInstanceCall)
# simple waiting loop hook - should do in most cases
# note the pre/post-conditions of a thread-critical state
@@ -109,7 +109,7 @@ module Singleton
super
sub_klass.instance_eval do @__instance__ = nil end
class << sub_klass
- define_method (:instance, Singleton::FirstInstanceCall)
+ define_method(:instance, Singleton::FirstInstanceCall)
end
end
@@ -120,7 +120,7 @@ module Singleton
res = super
res.instance_eval do @__instance__ = nil end
class << res
- define_method (:instance, Singleton::FirstInstanceCall)
+ define_method(:instance, Singleton::FirstInstanceCall)
end
res
end
@@ -215,7 +215,7 @@ class Ups < SomeSingletonClass
@__instance__
end
def __sleep
- sleep (rand(0.08))
+ sleep(rand(0.08))
end
def allocate
__sleep
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index a0c7f4cf3f..fd03b2ccc8 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -85,6 +85,15 @@ class Tempfile < SimpleDelegator
def path
@tmpname
end
+
+ def size
+ if @tmpfile
+ @tmpfile.flush
+ @tmpfile.stat.size
+ else
+ 0
+ end
+ end
end
if __FILE__ == $0