class OnlyofficeGmailHelper::MailMessage

Class for working with single message

Attributes

content[RW]

@return [String] mail content

date[RW]

@return [String] date field

reply_to[RW]

@return [String] reply to field

tags[RW]

@return [String] tags field

title[RW]

@return [String] mail title

Public Class Methods

new(title, content = nil, reply_to = nil, date = nil, tags = nil) click to toggle source
# 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

Public Instance Methods

==(other) click to toggle source

Compare message with other @param [MailMessage] other to compare @return [Boolean] result

# 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