Class: OnlyofficeGmailHelper::MailMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/onlyoffice_gmail_helper/mail_message.rb

Overview

Class for working with single message

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, content = nil, reply_to = nil, date = nil, tags = nil) ⇒ MailMessage

Returns a new instance of MailMessage.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/onlyoffice_gmail_helper/mail_message.rb', line 17

def initialize(title, content = nil, reply_to = nil, date = nil, tags = nil)
  @title = title
  @content = content
  @reply_to = reply_to
  unless @content.nil? && !content.is_a?(Regexp)
    begin
      @content.delete!("\n")
    rescue StandardError
      Exception
    end
    begin
      @content.gsub!("\r\n", '')
    rescue StandardError
      Exception
    end
    begin
      @content.gsub!("\n\n", '')
    rescue StandardError
      Exception
    end
    begin
      @content.gsub!('“', '"')
    rescue StandardError
      Exception
    end
    begin
      @content.gsub!('”', '"')
    rescue StandardError
      Exception
    end
    begin
      @content.tr!("\r", ' ')
    rescue StandardError
      Exception
    end
  end
  @date = date
  @tags = tags
end

Instance Attribute Details

#contentString

Returns mail content.

Returns:

  • (String)

    mail content



9
10
11
# File 'lib/onlyoffice_gmail_helper/mail_message.rb', line 9

def content
  @content
end

#dateString

Returns date field.

Returns:

  • (String)

    date field



13
14
15
# File 'lib/onlyoffice_gmail_helper/mail_message.rb', line 13

def date
  @date
end

#reply_toString

Returns reply to field.

Returns:

  • (String)

    reply to field



11
12
13
# File 'lib/onlyoffice_gmail_helper/mail_message.rb', line 11

def reply_to
  @reply_to
end

#tagsString

Returns tags field.

Returns:

  • (String)

    tags field



15
16
17
# File 'lib/onlyoffice_gmail_helper/mail_message.rb', line 15

def tags
  @tags
end

#titleString

Returns mail title.

Returns:

  • (String)

    mail title



7
8
9
# File 'lib/onlyoffice_gmail_helper/mail_message.rb', line 7

def title
  @title
end

Instance Method Details

#==(other) ⇒ Boolean

Compare message with other

Parameters:

Returns:

  • (Boolean)

    result



60
61
62
63
64
65
# File 'lib/onlyoffice_gmail_helper/mail_message.rb', line 60

def ==(other)
  compare_title = (title.delete("\n") == other.title.delete("\n"))
  compare_body = true
  compare_body = false if (StaticDataTeamLab.check_email_body if defined?(StaticDataTeamLab.check_email_body)) && compare_title && (other.content =~ content).nonzero?
  compare_title && compare_body
end