Class: Archive::Pecan::Blob

Inherits:
Object
  • Object
show all
Defined in:
lib/archive/pecan/blob.rb

Overview

Abstract representation of a binary blob in an component archive.

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mime_type, blob) ⇒ Blob

Initializes the blob object with data.

Parameters:

  • mime_type (String)

    MIME type of the binary blob.

  • blob (#read)

    Blob of binary data.



22
23
24
25
# File 'lib/archive/pecan/blob.rb', line 22

def initialize(mime_type, blob)
  @mime_type = mime_type
  @blob = blob
end

Instance Attribute Details

#blob#read

Returns Blob of binary data.

Returns:

  • (#read)

    Blob of binary data.



16
17
18
# File 'lib/archive/pecan/blob.rb', line 16

def blob
  @blob
end

#mime_typeString

Returns MIME type of the data contained in the blob.

Returns:

  • (String)

    MIME type of the data contained in the blob.



13
14
15
# File 'lib/archive/pecan/blob.rb', line 13

def mime_type
  @mime_type
end

Instance Method Details

#to_sString

String representation of the binary blob.

Returns:

  • (String)

    Base64-encoded URI string of the binary data.



30
31
32
# File 'lib/archive/pecan/blob.rb', line 30

def to_s
  "data:#{@mime_type};charset=utf-8;base64,#{Base64.encode64(@blob)}"
end

#to_strObject

See Also:



35
36
37
# File 'lib/archive/pecan/blob.rb', line 35

def to_str
  to_s
end