Module: MogileFS::NewFile::Writer
- Defined in:
- lib/mogilefs/new_file/writer.rb
Overview
All objects yielded or returned by MogileFS::MogileFS#new_file should conform to this interface (based on existing IO methods). These objects should be considered write-only.
Instance Method Summary collapse
-
#<<(str) ⇒ Object
see IO#<<.
-
#close ⇒ Object
This will issue the
create_close
command to the MogileFS tracker and finalize the creation of a new file. -
#print(*args) ⇒ Object
see IO#print.
-
#printf(*args) ⇒ Object
see IO#printf.
-
#putc(ch) ⇒ Object
see IO#putc.
-
#puts(*args) ⇒ Object
see IO#puts.
Instance Method Details
#<<(str) ⇒ Object
see IO#<<
42 43 44 45 |
# File 'lib/mogilefs/new_file/writer.rb', line 42 def <<(str) write(str) self end |
#close ⇒ Object
This will issue the create_close
command to the MogileFS tracker and finalize the creation of a new file. This returns nil
on success and will raise IOError if called twice. For non-streaming implementations, this will initiate and finalize the upload.
see IO#close
53 54 55 56 |
# File 'lib/mogilefs/new_file/writer.rb', line 53 def close commit nil end |
#print(*args) ⇒ Object
see IO#print
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mogilefs/new_file/writer.rb', line 24 def print(*args) args = [ $_ ] unless args[0] write(args.shift) args.each do |obj| write(obj) write($,) if $, end write($\) if $\ nil end |
#printf(*args) ⇒ Object
see IO#printf
36 37 38 39 |
# File 'lib/mogilefs/new_file/writer.rb', line 36 def printf(*args) write(sprintf(*args)) nil end |
#putc(ch) ⇒ Object
see IO#putc
18 19 20 21 |
# File 'lib/mogilefs/new_file/writer.rb', line 18 def putc(ch) write(ch.respond_to?(:chr) ? ch.chr : ch[0]) ch end |
#puts(*args) ⇒ Object
see IO#puts
9 10 11 12 13 14 15 |
# File 'lib/mogilefs/new_file/writer.rb', line 9 def puts(*args) args.each do |obj| write(obj) write("\n".freeze) end nil end |