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.



241
242
243
244
245
246
247
# File 'lib/email_reply_parser.rb', line 241

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.



235
236
237
# File 'lib/email_reply_parser.rb', line 235

def content
  @content
end

#hiddenObject Also known as: hidden?

Returns the value of attribute hidden

Returns:

  • (Object)

    the current value of hidden



232
233
234
# File 'lib/email_reply_parser.rb', line 232

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.



235
236
237
# File 'lib/email_reply_parser.rb', line 235

def lines
  @lines
end

#quotedObject Also known as: quoted?

Returns the value of attribute quoted

Returns:

  • (Object)

    the current value of quoted



232
233
234
# File 'lib/email_reply_parser.rb', line 232

def quoted
  @quoted
end

#signatureObject Also known as: signature?

Returns the value of attribute signature

Returns:

  • (Object)

    the current value of signature



232
233
234
# File 'lib/email_reply_parser.rb', line 232

def signature
  @signature
end

Instance Method Details

#finishObject

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

Returns nothing.



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

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

#inspectObject



266
267
268
# File 'lib/email_reply_parser.rb', line 266

def inspect
  to_s.inspect
end

#to_sObject



262
263
264
# File 'lib/email_reply_parser.rb', line 262

def to_s
  @content
end