Class: Riiif::File
- Inherits:
-
Object
- Object
- Riiif::File
- Defined in:
- app/models/riiif/file.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #extract(transformation) ⇒ Object
- #info ⇒ Object
-
#initialize(input_path, tempfile = nil) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(input_path, tempfile = nil) ⇒ File
Returns a new instance of File.
9 10 11 12 |
# File 'app/models/riiif/file.rb', line 9 def initialize(input_path, tempfile = nil) @path = input_path @tempfile = tempfile # ensures that the tempfile will stick around until this file is garbage collected. end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'app/models/riiif/file.rb', line 3 def path @path end |
Class Method Details
.create(ext = nil, _validate = true, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'app/models/riiif/file.rb', line 23 def self.create(ext = nil, _validate = true, &block) tempfile = Tempfile.new(['mini_magick', ext.to_s.downcase]) tempfile.binmode block.call(tempfile) tempfile.close image = new(tempfile.path, tempfile) ensure tempfile.close if tempfile end |
.read(stream, ext) ⇒ Object
14 15 16 17 18 19 20 |
# File 'app/models/riiif/file.rb', line 14 def self.read(stream, ext) create(ext) do |f| while chunk = stream.read(8192) f.write(chunk) end end end |
Instance Method Details
#extract(transformation) ⇒ Object
35 36 37 38 |
# File 'app/models/riiif/file.rb', line 35 def extract(transformation) command = command_factory.build(path, transformation) execute(command) end |
#info ⇒ Object
40 41 42 |
# File 'app/models/riiif/file.rb', line 40 def info @info ||= info_extractor_class.new(path).extract end |