projects
/
quanlib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add `arrived` attribute (file creation timestamp) to books table.
[quanlib.git]
/
cover.rb
diff --git
a/cover.rb
b/cover.rb
index b88f3406267c9963822e46b3eae3c3e3a14081fa..e74c27ba6cc42726f69804fd3ac3904b715aa5cc 100644
(file)
--- a/
cover.rb
+++ b/
cover.rb
@@
-1,7
+1,13
@@
class Cover
class Cover
+ attr_reader :path
+
def initialize(inputStream, path, mimeType)
def initialize(inputStream, path, mimeType)
- @data = inputStream.read
+ if nil != inputStream
+ @data = inputStream.read
+ else
+ @data = nil
+ end
@path = path
@mimeType = mimeType
end
@path = path
@mimeType = mimeType
end
@@
-22,12
+28,17
@@
class Cover
return '(Cover:' + info.join(',') + ')'
end
return '(Cover:' + info.join(',') + ')'
end
+ def read_image(filename)
+ open(filename, 'rb') do |fd|
+ @data = fd.read()
+ end
+ end
+
def to_s
return inspect
end
def to_s
return inspect
end
- def writeImage(outputDir, baseName)
- filename = baseName + getExt()
+ def write_image(outputDir, filename)
open(outputDir + '/' + filename, 'wb') do |fd|
fd.write(@data)
end
open(outputDir + '/' + filename, 'wb') do |fd|
fd.write(@data)
end