Skip to content
Browse files

Add IO#advise (1.9.3)

  • Loading branch information...
1 parent e7e9040 commit 4013a5f29e1722e4f8e23c573fa97dbce2761d01 @marcandre committed
Showing with 21 additions and 0 deletions.
  1. +1 −0 README.rdoc
  2. +20 −0 lib/backports/1.9.3/io.rb
View
1 README.rdoc
@@ -183,6 +183,7 @@ Some features of Ruby 1.9.3 have been backported:
* File
* +NULL+
* IO
+ * +advise+ (acts as a noop)
* +write+, +binwrite+
* String
* +byteslice+
View
20 lib/backports/1.9.3/io.rb
@@ -1,3 +1,23 @@
+class IO
+ # Standard in Ruby 1.9.3 See official documentation[http://ruby-doc.org/core-1.9.3/IO.html#method-i-advise]
+ # We're only for a platform not implementing advise, so we return nil.
+ def advise(advice, offset=0, len=0)
+ case advice
+ when :normal,
+ :sequential,
+ :random,
+ :willneed,
+ :dontneed,
+ :noreuse
+ return nil
+ when Symbol
+ raise NotImplementedError, "Unsupported advice #{advice}"
+ else
+ raise TypeError, "advice must be a Symbol"
+ end
+ end unless method_defined? :advise
+end
+
class << IO
# Standard in Ruby 1.9.3 See official documentation[http://ruby-doc.org/core-1.9.3/IO.html#method-c-write]
def write(name, string, offset = nil, options = Backports::Undefined)

0 comments on commit 4013a5f

Please sign in to comment.
Something went wrong with that request. Please try again.