class Mailbot::Entry

Constants

HEADER_LINE_PATTERN
SYNC_MARK

Attributes

text[RW]

Public Class Methods

new(text) click to toggle source

@param text [String] The raw text of this entry

# File lib/mailbot/entry.rb, line 11
def initialize(text)
  @text = text
end

Public Instance Methods

render_body() click to toggle source

@return [String] An HTML representation of this entry

# File lib/mailbot/entry.rb, line 21
def render_body
  Mailbot::Renderer.render @text.sub(HEADER_LINE_PATTERN, "")
end
subject() click to toggle source

@return [String] A subject of this entry

# File lib/mailbot/entry.rb, line 16
def subject
  headers.reject { |header| header =~ /#{SYNC_MARK}/ }.first
end
sync() click to toggle source

@return [Mailbot::Entry] A synced entry

# File lib/mailbot/entry.rb, line 31
def sync
  Entry.new(@text.sub HEADER_LINE_PATTERN, "# #{SYNC_MARK} \\2")
end
synced?() click to toggle source

@return [Boolean] True if this entry is already synced to Mailbox

# File lib/mailbot/entry.rb, line 26
def synced?
  headers.include? SYNC_MARK
end
to_s() click to toggle source

@note Overridden @return [String] A String representation of this entry

# File lib/mailbot/entry.rb, line 37
def to_s
  @text
end

Private Instance Methods

headers() click to toggle source
# File lib/mailbot/entry.rb, line 79
def headers
  @text.scan(HEADER_LINE_PATTERN).flatten.compact.map(&:strip)
end