Class: EmailReplyParser::Fragment
- Inherits:
-
Struct
- Object
- Struct
- EmailReplyParser::Fragment
- 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
-
#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.
407 408 409 410 411 412 |
# File 'lib/email_reply_parser.rb', line 407 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.
405 406 407 |
# File 'lib/email_reply_parser.rb', line 405 def content @content end |
#current_block ⇒ Object (readonly)
Array of string lines that is being processed not having an empty line.
401 402 403 |
# File 'lib/email_reply_parser.rb', line 401 def current_block @current_block end |
#hidden ⇒ Object Also known as:
Returns the value of attribute hidden
395 396 397 |
# File 'lib/email_reply_parser.rb', line 395 def hidden @hidden end |
#lines ⇒ Object (readonly)
Array of string lines that make up the content of this fragment.
397 398 399 |
# File 'lib/email_reply_parser.rb', line 397 def lines @lines end |
#quoted ⇒ Object Also known as: quoted?
Returns the value of attribute quoted
395 396 397 |
# File 'lib/email_reply_parser.rb', line 395 def quoted @quoted end |
#reply_header ⇒ Object Also known as: reply_header?
Returns the value of attribute reply_header
395 396 397 |
# File 'lib/email_reply_parser.rb', line 395 def reply_header @reply_header end |
#signature ⇒ Object Also known as: signature?
Returns the value of attribute signature
395 396 397 |
# File 'lib/email_reply_parser.rb', line 395 def signature @signature end |
Instance Method Details
#add_line(line) ⇒ Object
419 420 421 422 423 424 425 426 427 |
# File 'lib/email_reply_parser.rb', line 419 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.
434 435 436 437 |
# File 'lib/email_reply_parser.rb', line 434 def finish @content = @lines.join("\n") @lines = @current_block = nil end |
#inspect ⇒ Object
443 444 445 |
# File 'lib/email_reply_parser.rb', line 443 def inspect "#{super.inspect} : #{to_s.inspect}" end |
#to_s ⇒ Object
439 440 441 |
# File 'lib/email_reply_parser.rb', line 439 def to_s @lines ? @lines.join("\n") : @content end |