require 'mail'
require 'base64'
require 'minyou/entities/body'

class TextMedia
  attr_accessor :size,:encoding,:charset,:lines,:body_id
  
  def set_body b
    @body = Body.new
    @body.body = b
    @body.encoding = @encoding
  end
  
  def body
    @body
  end
  
  def decoded
    if @body 
      if @encoding == 'BASE64'
        Base64.decode64 @body.body
      elsif @encoding == 'QUOTED-PRINTABLE'
        Mail::Encodings::QuotedPrintable.decode @body.body
      else
        @body.body
      end
    else
      nil
    end
  end
end