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.



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

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.



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

def content_type
  @content_type
end

#encodingObject

Returns the value of attribute encoding.



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

def encoding
  @encoding
end

#extensionObject

Returns the value of attribute extension.



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

def extension
  @extension
end

Instance Method Details

#[](idx) ⇒ Object



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

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

#binary?Boolean

Returns:

  • (Boolean)


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

def binary?
  BINARY_ENCODINGS.include?(encoding)
end