Class: FormatParser::ActiveStorage::BlobAnalyzer
- Inherits:
-
Object
- Object
- FormatParser::ActiveStorage::BlobAnalyzer
- Defined in:
- lib/active_storage/blob_analyzer.rb
Class Method Summary collapse
-
.accept?(_blob) ⇒ Boolean, true
Format parser is able to handle a lot of format so by default it will accept all files.
Instance Method Summary collapse
-
#initialize(blob) ⇒ BlobAnalyzer
constructor
A new instance of BlobAnalyzer.
-
#metadata ⇒ Hash
File metadatas.
Constructor Details
#initialize(blob) ⇒ BlobAnalyzer
Returns a new instance of BlobAnalyzer.
17 18 19 |
# File 'lib/active_storage/blob_analyzer.rb', line 17 def initialize(blob) @blob = blob end |
Class Method Details
.accept?(_blob) ⇒ Boolean, true
Format parser is able to handle a lot of format so by default it will accept all files
13 14 15 |
# File 'lib/active_storage/blob_analyzer.rb', line 13 def self.accept?(_blob) true end |
Instance Method Details
#metadata ⇒ Hash
Returns file metadatas.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/active_storage/blob_analyzer.rb', line 22 def io = BlobIO.new(@blob) parsed_file = FormatParser.parse(io) if parsed_file # We symbolize keys because of existing output hash format of ImageAnalyzer parsed_file.as_json.symbolize_keys else logger.info "Skipping file analysis because FormatParser doesn't support the file" end end |