Class: EmailReplyParser::Fragment

Inherits:
Struct
  • Object
show all
Defined in:
lib/email_reply_parser.rb

Overview

Represents a group of paragraphs in the email sharing common attributes. Paragraphs should get their own fragment if they are a quoted area or a signature.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(quoted, first_line) ⇒ Fragment

Returns a new instance of Fragment.



235
236
237
238
239
240
241
# File 'lib/email_reply_parser.rb', line 235

def initialize(quoted, first_line)
  self.signature = self.hidden = false
  self.quoted = quoted
  @lines      = [first_line]
  @content    = nil
  @lines.compact!
end

Instance Attribute Details

#contentObject (readonly)

This is an Array of String lines of content. Since the content is reversed, this array is backwards, and contains reversed strings.



229
230
231
# File 'lib/email_reply_parser.rb', line 229

def content
  @content
end

#hiddenObject Also known as: hidden?

Returns the value of attribute hidden

Returns:

  • (Object)

    the current value of hidden



226
227
228
# File 'lib/email_reply_parser.rb', line 226

def hidden
  @hidden
end

#linesObject (readonly)

This is an Array of String lines of content. Since the content is reversed, this array is backwards, and contains reversed strings.



229
230
231
# File 'lib/email_reply_parser.rb', line 229

def lines
  @lines
end

#quotedObject Also known as: quoted?

Returns the value of attribute quoted

Returns:

  • (Object)

    the current value of quoted



226
227
228
# File 'lib/email_reply_parser.rb', line 226

def quoted
  @quoted
end

#signatureObject Also known as: signature?

Returns the value of attribute signature

Returns:

  • (Object)

    the current value of signature



226
227
228
# File 'lib/email_reply_parser.rb', line 226

def signature
  @signature
end

Instance Method Details

#finishObject

Builds the string content by joining the lines and reversing them.

Returns nothing.



250
251
252
253
254
# File 'lib/email_reply_parser.rb', line 250

def finish
  @content = @lines.join("\n")
  @lines = nil
  @content.reverse!
end

#inspectObject



260
261
262
# File 'lib/email_reply_parser.rb', line 260

def inspect
  to_s.inspect
end

#to_sObject



256
257
258
# File 'lib/email_reply_parser.rb', line 256

def to_s
  @content
end