Class: MiniMime::Info

Inherits:
Object
  • Object
show all
Defined in:
lib/mini_mime.rb

Constant Summary collapse

BINARY_ENCODINGS =
%w(base64 8bit)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buffer) ⇒ Info

Returns a new instance of Info.



32
33
34
# File 'lib/mini_mime.rb', line 32

def initialize(buffer)
  @extension, @content_type, @encoding = buffer.split(/\s+/).map!(&:freeze)
end

Instance Attribute Details

#content_typeObject

Returns the value of attribute content_type.



30
31
32
# File 'lib/mini_mime.rb', line 30

def content_type
  @content_type
end

#encodingObject

Returns the value of attribute encoding.



30
31
32
# File 'lib/mini_mime.rb', line 30

def encoding
  @encoding
end

#extensionObject

Returns the value of attribute extension.



30
31
32
# File 'lib/mini_mime.rb', line 30

def extension
  @extension
end

Instance Method Details

#[](idx) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/mini_mime.rb', line 36

def [](idx)
  if idx == 0
    @extension
  elsif idx == 1
    @content_type
  elsif idx == 2
    @encoding
  end
end

#binary?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/mini_mime.rb', line 46

def binary?
  BINARY_ENCODINGS.include?(encoding)
end