class Mailbot::Entry::Parser
Public Class Methods
new()
click to toggle source
# File lib/mailbot/entry.rb, line 43 def initialize @entries = [] @buffer = "" end
Public Instance Methods
parse(text)
click to toggle source
@param text [String] The raw text to parse to entries @return [Array<Mailbot::Entry>] An Array of parsed entries
# 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
Private Instance Methods
flush()
click to toggle source
# File lib/mailbot/entry.rb, line 66 def flush unless @buffer.empty? @entries << Entry.new("#{@buffer.strip}\n") true else false end end