Class: Mailbot::Entry::Parser
- Inherits:
-
Object
- Object
- Mailbot::Entry::Parser
- Defined in:
- lib/mailbot/entry.rb
Instance Method Summary collapse
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
-
#parse(text) ⇒ Array<Mailbot::Entry>
An Array of parsed entries.
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
43 44 45 46 |
# File 'lib/mailbot/entry.rb', line 43 def initialize @entries = [] @buffer = "" end |
Instance Method Details
#parse(text) ⇒ Array<Mailbot::Entry>
Returns An Array of parsed entries.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/mailbot/entry.rb', line 50 def parse(text) text.strip.each_line do |line| if @buffer.empty? @buffer = line elsif line =~ HEADER_LINE_PATTERN @buffer = line if flush else @buffer << line end end flush @entries end |