Class: Mailbot::Entry
- Inherits:
-
Object
- Object
- Mailbot::Entry
- Defined in:
- lib/mailbot/entry.rb
Defined Under Namespace
Classes: Parser
Constant Summary collapse
- SYNC_MARK =
"✓"- HEADER_LINE_PATTERN =
/^#\s+(#{SYNC_MARK}\s*)?(.+)$/
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text) ⇒ Entry
constructor
A new instance of Entry.
-
#render_body ⇒ String
An HTML representation of this entry.
-
#subject ⇒ String
A subject of this entry.
-
#sync ⇒ Mailbot::Entry
A synced entry.
-
#synced? ⇒ Boolean
True if this entry is already synced to Mailbox.
-
#to_s ⇒ String
A String representation of this entry.
Constructor Details
#initialize(text) ⇒ Entry
Returns a new instance of Entry.
11 12 13 |
# File 'lib/mailbot/entry.rb', line 11 def initialize(text) @text = text end |
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
8 9 10 |
# File 'lib/mailbot/entry.rb', line 8 def text @text end |
Instance Method Details
#render_body ⇒ String
Returns An HTML representation of this entry.
21 22 23 |
# File 'lib/mailbot/entry.rb', line 21 def render_body Mailbot::Renderer.render @text.sub(HEADER_LINE_PATTERN, "") end |
#subject ⇒ String
Returns A subject of this entry.
16 17 18 |
# File 'lib/mailbot/entry.rb', line 16 def subject headers.reject { |header| header =~ /#{SYNC_MARK}/ }.first end |
#sync ⇒ Mailbot::Entry
Returns A synced entry.
31 32 33 |
# File 'lib/mailbot/entry.rb', line 31 def sync Entry.new(@text.sub HEADER_LINE_PATTERN, "# #{SYNC_MARK} \\2") end |
#synced? ⇒ Boolean
Returns True if this entry is already synced to Mailbox.
26 27 28 |
# File 'lib/mailbot/entry.rb', line 26 def synced? headers.include? SYNC_MARK end |
#to_s ⇒ String
Note:
Overridden
Returns A String representation of this entry.
37 38 39 |
# File 'lib/mailbot/entry.rb', line 37 def to_s @text end |