Class: MailCatcher::API::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/mailcatcher/api/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_message) ⇒ Message

Returns a new instance of Message.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mailcatcher/api/message.rb', line 12

def initialize(raw_message)
  mail = Mail.new(raw_message)

  @raw = raw_message
  @message_id = mail.message_id
  @date = mail.date
  @from = mail.from
  @to = mail.to
  @subject = mail.subject
  @body = mail.body.raw_source
  @mime_type = mail.mime_type
  @charset = mail.charset
  @content_type = mail.content_type
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



9
10
11
# File 'lib/mailcatcher/api/message.rb', line 9

def body
  @body
end

#charsetObject (readonly)

Returns the value of attribute charset.



10
11
12
# File 'lib/mailcatcher/api/message.rb', line 10

def charset
  @charset
end

#content_typeObject (readonly)

Returns the value of attribute content_type.



10
11
12
# File 'lib/mailcatcher/api/message.rb', line 10

def content_type
  @content_type
end

#dateObject (readonly)

Returns the value of attribute date.



8
9
10
# File 'lib/mailcatcher/api/message.rb', line 8

def date
  @date
end

#fromObject (readonly)

Returns the value of attribute from.



9
10
11
# File 'lib/mailcatcher/api/message.rb', line 9

def from
  @from
end

#message_idObject (readonly)

Returns the value of attribute message_id.



8
9
10
# File 'lib/mailcatcher/api/message.rb', line 8

def message_id
  @message_id
end

#mime_typeObject (readonly)

Returns the value of attribute mime_type.



10
11
12
# File 'lib/mailcatcher/api/message.rb', line 10

def mime_type
  @mime_type
end

#rawObject (readonly)

Returns the value of attribute raw.



7
8
9
# File 'lib/mailcatcher/api/message.rb', line 7

def raw
  @raw
end

#subjectObject (readonly)

Returns the value of attribute subject.



9
10
11
# File 'lib/mailcatcher/api/message.rb', line 9

def subject
  @subject
end

#toObject (readonly)

Returns the value of attribute to.



9
10
11
# File 'lib/mailcatcher/api/message.rb', line 9

def to
  @to
end

Instance Method Details



27
28
29
# File 'lib/mailcatcher/api/message.rb', line 27

def links
  @links ||= URI.extract(@body).select { |s| s.start_with? 'http' }
end