diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-08-08 19:48:12 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-08-08 19:48:12 -0700 |
commit | 681bf1fc481883293a47def022267577224e53b8 (patch) | |
tree | cbaef94742ca5e6c7634cb3e56803def4782c755 /activesupport/lib | |
parent | 0b212117e60bf6778def3bd9c2521f92f0c74c73 (diff) | |
download | rails-681bf1fc481883293a47def022267577224e53b8.tar.gz rails-681bf1fc481883293a47def022267577224e53b8.tar.bz2 rails-681bf1fc481883293a47def022267577224e53b8.zip |
backporting IO#binread for 1.8 users
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/io.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/io.rb b/activesupport/lib/active_support/core_ext/io.rb new file mode 100644 index 0000000000..75f1055191 --- /dev/null +++ b/activesupport/lib/active_support/core_ext/io.rb @@ -0,0 +1,15 @@ +if RUBY_VERSION < '1.9.2' + +# :stopdoc: +class IO + def self.binread(name, length = nil, offset = nil) + return File.read name unless length || offset + File.open(name, 'rb') { |f| + f.seek offset if offset + f.read length + } + end +end +# :startdoc: + +end |