lib/email_reply_parser.rb
def scan_line(line)
      line.chomp!("\n")
      line.lstrip! unless signature_line?(line)

      # We're looking for leading `>`'s to see if this line is part of a
      # quoted Fragment.
      is_quoted = !!(line =~ /(>+)$/n)

      # Mark the current Fragment as a signature if the current line is empty
      # and the Fragment starts with a common signature indicator.
      if @fragment && line == EMPTY
        last_line = @fragment.lines.last
        is_signature = signature_line?(last_line) 
        is_multiline_quote_header = multiline_quote_header_in_fragment?(@fragment)

        if is_signature || is_multiline_quote_header
          if is_signature
            @fragment.signature = true
          else 
            @fragment.quoted = true
          end
          finish_fragment
        end
      end

      # If the line matches the current fragment, add it.  Note that a common
      # reply header also counts as part of the quoted Fragment, even though
      # it doesn't start with `>`.
      if @fragment &&
          ((@fragment.quoted? == is_quoted) ||
           (@fragment.quoted? && (quote_header?(line) || line == EMPTY)))
        @fragment.lines << line

      # Otherwise, finish the fragment and start a new one.
      else
        finish_fragment
        @fragment = Fragment.new(is_quoted, line)
      end
    end
# Scans the given line of text and figures out which fragment it belongs
# to.
#
# line - A String line of text from the email.
#
# Returns nothing.
Scans the given line of text and figures out which fragment it belongs
to.

A String line of text from the email.

Returns nothing.
Scans the given line of text and figures out which fragment it belongs to . A String line of text from the email . Returns nothing .
def scan_line(line)
      line.chomp!("\n")
      line.lstrip! unless signature_line?(line)
      is_quoted = !!(line =~ /(>+)$/n)
      if @fragment && line == EMPTY
        last_line = @fragment.lines.last
        is_signature = signature_line?(last_line) 
        is_multiline_quote_header = multiline_quote_header_in_fragment?(@fragment)
        if is_signature || is_multiline_quote_header
          if is_signature
            @fragment.signature = true
          else 
            @fragment.quoted = true
          end
          finish_fragment
        end
      end
      if @fragment &&
          ((@fragment.quoted? == is_quoted) ||
           (@fragment.quoted? && (quote_header?(line) || line == EMPTY)))
        @fragment.lines << line
      else
        finish_fragment
        @fragment = Fragment.new(is_quoted, line)
      end
    end
def scan_line ( line ) line . chomp! ( "\n" ) line . lstrip! unless signature_line? ( line ) is_quoted = ! ! ( line =~ / (>+)$ /n ) if @fragment && line == EMPTY last_line = @fragment . lines . last is_signature = signature_line? ( last_line ) is_multiline_quote_header = multiline_quote_header_in_fragment? ( @fragment ) if is_signature || is_multiline_quote_header if is_signature @fragment . signature = true else @fragment . quoted = true end finish_fragment end end if @fragment && ( ( @fragment . quoted? == is_quoted ) || ( @fragment . quoted? && ( quote_header? ( line ) || line == EMPTY ) ) ) @fragment . lines << line else finish_fragment @fragment = Fragment . new ( is_quoted , line ) end end
Scans the given line of text and figures out which fragment it belongs
to.
Scans the given line of text and figures out which fragment it belongs to .
# We're looking for leading `>`'s to see if this line is part of a # quoted Fragment. # Mark the current Fragment as a signature if the current line is empty # and the Fragment starts with a common signature indicator. # If the line matches the current fragment, add it.  Note that a common # reply header also counts as part of the quoted Fragment, even though # it doesn't start with `>`. # Otherwise, finish the fragment and start a new one.
line