Class: EdifactConverter::Binary
- Inherits:
-
Object
- Object
- EdifactConverter::Binary
- Defined in:
- lib/edifact_converter/binary.rb
Constant Summary collapse
- MIME_TYPES =
{ "pcx" => 'image/x-pcx', "tiff" => 'image/tiff', "jpeg" => 'image/jpeg', "gif" => 'image/gif', "bmp" => 'image/bmp', "png" => 'image/png', "mpg" => 'video/mpeg', "dcm" => 'application/dicom', "scp" => 'application/dicom', "txt" => 'text/plain', "rtf" => 'text/rtf', "doc" => 'application/msword', "xls" => 'application/vnd.ms-excel', "wpd" => 'application/wordperfect', "exe" => 'application/octet-stream', "pdf" => 'application/pdf', "wav" => 'audio/wav', "avi" => 'video/avi', "mid" => 'audio/midi', "rmi" => 'audio/mid', "com" => 'application/octet-stream', "zip" => 'application/zip', 'bin' => 'application/octet-stream', 'inh' => 'application/octet-stream', 'fnx' => 'application/zip' }
- ATTRIBUTES =
[:base64, :code, :extension, :size, :identifier]
Class Method Summary collapse
Instance Method Summary collapse
- #binary ⇒ Object
-
#initialize(options) ⇒ Binary
constructor
A new instance of Binary.
- #mime_type ⇒ Object
Constructor Details
#initialize(options) ⇒ Binary
Returns a new instance of Binary.
41 42 43 44 45 46 47 |
# File 'lib/edifact_converter/binary.rb', line 41 def initialize() .each do |name, value| if ATTRIBUTES.include? name.to_sym send "#{name}=", value end end end |
Class Method Details
.from_element(element) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/edifact_converter/binary.rb', line 57 def self.from_element(element) self.new( base64: element.at("Object_Base64Encoded/text()").to_s, code: element.at("ObjectCode/text()").to_s, extension: element.at("ObjectExtensionCode/text()").to_s, size: element.at("OriginalObjectSize/text()").to_s, identifier: element.at("ObjectIdentifier/text()").to_s ) end |
Instance Method Details
#binary ⇒ Object
49 50 51 |
# File 'lib/edifact_converter/binary.rb', line 49 def binary Base64.decode64 base64 end |
#mime_type ⇒ Object
53 54 55 |
# File 'lib/edifact_converter/binary.rb', line 53 def mime_type MIME_TYPES.fetch extension, "application/octet-stream" end |