Class: EmailReplyParser::Fragment
- Inherits:
-
Struct
- Object
- Struct
- EmailReplyParser::Fragment
- Defined in:
- lib/email_reply_parser/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
-
#content ⇒ Object
readonly
This is reserved for the joined String that is build when this Fragment is finished.
-
#current_block ⇒ Object
readonly
Array of string lines that is being processed not having an empty line.
-
#hidden ⇒ Object
(also: #hidden?)
Returns the value of attribute hidden.
-
#lines ⇒ Object
readonly
Array of string lines that make up the content of this fragment.
-
#quoted ⇒ Object
(also: #quoted?)
Returns the value of attribute quoted.
-
#reply_header ⇒ Object
(also: #reply_header?)
Returns the value of attribute reply_header.
-
#signature ⇒ Object
(also: #signature?)
Returns the value of attribute signature.
Instance Method Summary collapse
- #add_line(line) ⇒ Object
-
#finish ⇒ Object
Builds the string content by joining the lines and reversing them.
-
#initialize ⇒ Fragment
constructor
A new instance of Fragment.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Fragment
Returns a new instance of Fragment.
434 435 436 437 438 439 |
# File 'lib/email_reply_parser/email_reply_parser.rb', line 434 def initialize self.quoted = self.signature = self.reply_header = self.hidden = false @lines = [] @current_block = [] @content = nil end |
Instance Attribute Details
#content ⇒ Object (readonly)
This is reserved for the joined String that is build when this Fragment is finished.
432 433 434 |
# File 'lib/email_reply_parser/email_reply_parser.rb', line 432 def content @content end |
#current_block ⇒ Object (readonly)
Array of string lines that is being processed not having an empty line.
428 429 430 |
# File 'lib/email_reply_parser/email_reply_parser.rb', line 428 def current_block @current_block end |
#hidden ⇒ Object Also known as:
Returns the value of attribute hidden
422 423 424 |
# File 'lib/email_reply_parser/email_reply_parser.rb', line 422 def hidden @hidden end |
#lines ⇒ Object (readonly)
Array of string lines that make up the content of this fragment.
424 425 426 |
# File 'lib/email_reply_parser/email_reply_parser.rb', line 424 def lines @lines end |
#quoted ⇒ Object Also known as: quoted?
Returns the value of attribute quoted
422 423 424 |
# File 'lib/email_reply_parser/email_reply_parser.rb', line 422 def quoted @quoted end |
#reply_header ⇒ Object Also known as: reply_header?
Returns the value of attribute reply_header
422 423 424 |
# File 'lib/email_reply_parser/email_reply_parser.rb', line 422 def reply_header @reply_header end |
#signature ⇒ Object Also known as: signature?
Returns the value of attribute signature
422 423 424 |
# File 'lib/email_reply_parser/email_reply_parser.rb', line 422 def signature @signature end |
Instance Method Details
#add_line(line) ⇒ Object
446 447 448 449 450 451 452 453 454 |
# File 'lib/email_reply_parser/email_reply_parser.rb', line 446 def add_line(line) return unless line @lines.insert(0, line) if line == "" @current_block.clear else @current_block.insert(0, line) end end |
#finish ⇒ Object
Builds the string content by joining the lines and reversing them.
461 462 463 464 |
# File 'lib/email_reply_parser/email_reply_parser.rb', line 461 def finish @content = @lines.join("\n") @lines = @current_block = nil end |
#inspect ⇒ Object
470 471 472 |
# File 'lib/email_reply_parser/email_reply_parser.rb', line 470 def inspect "#{super.inspect} : #{to_s.inspect}" end |
#to_s ⇒ Object
466 467 468 |
# File 'lib/email_reply_parser/email_reply_parser.rb', line 466 def to_s @lines ? @lines.join("\n") : @content end |