Class: LetterBomb::Preview::Action

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/letter_bomb/preview.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, mail, options = {}) ⇒ Action

Returns a new instance of Action.



52
53
54
55
56
# File 'lib/letter_bomb/preview.rb', line 52

def initialize(name, mail, options={})
  @name   = name
  @mail   = mail
  @format = options[:format] || default_format
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



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

def format
  @format
end

#mailObject (readonly)

Returns the value of attribute mail.



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

def mail
  @mail
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#bodyObject



58
59
60
61
62
63
# File 'lib/letter_bomb/preview.rb', line 58

def body
  return mail.body unless multipart?

  content_type = Rack::Mime.mime_type(".#{format}")
  (find_part_with_content_type(content_type) || mail.parts.first).body
end

#html_format?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/letter_bomb/preview.rb', line 65

def html_format?
  format == "html"
end