1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
| | # -*- encoding: binary -*-
#
# 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.
module MogileFS::NewFile::Writer
# see IO#puts
def puts(*args)
args.each do |obj|
write(obj)
write("\n".freeze)
end
nil
end
# see IO#putc
def putc(ch)
write(ch.respond_to?(:chr) ? ch.chr : ch[0])
ch
end
# see IO#print
def print(*args)
args = [ $_ ] unless args[0]
write(args.shift)
args.each do |obj|
write(obj)
write($,) if $,
end
write($\) if $\
nil
end
# see IO#printf
def printf(*args)
write(sprintf(*args))
nil
end
# see IO#<<
def <<(str)
write(str)
self
end
# 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
def close
commit
nil
end
end
|