class Attachment include ActiveModel::Validations include ActiveModel::Conversion extend ActiveModel::Naming attr_accessor :type, :charset, :encoding, :name, :description, :content, :message_id, :idx attr_reader :link def initialize(attributes = {}) attributes.each do |name, value| send("#{name}=", value) end if @type =~ /name=(\S+)/ @name = $1 @type =~ /^(\S+);/ @type = $1 else @name = "no_name.dat" end end def persisted? false end def to_s s = "Attachment:\n" instance_variables.sort.each do |name| if name == "@content" s += "\t#{name}: size #{instance_variable_get(name).size}\n" else s += "\t#{name}: #{instance_variable_get(name)}\n" end end s end def title @description.nil? ? @name : @description end def type @type.nil? ? '' : @type end def charset @charset.nil? ? '' : @charset end def encoding @encoding.nil? ? '' : @encoding end # def to_html # html = "
" # end # def to_table # html = "" ## @type.nil? ? html << "