Class: MailExtract::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/mail_extract/line.rb

Constant Summary collapse

PATTERNS =
{
  /^[>]+\s?/    => :quote,
  /^--/         => :signature,
  /^-- /        => :signature,
  /^[_]{2,}\n?/ => :signature,
  /^[-]{2,}\n?/ => :signature
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ Line

Returns a new instance of Line.



13
14
15
16
# File 'lib/mail_extract/line.rb', line 13

def initialize(str)
  @body = str
  detect_type(str)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/mail_extract/line.rb', line 3

def body
  @body
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/mail_extract/line.rb', line 3

def type
  @type
end

Instance Method Details

#quote?Boolean

Returns true if line was detected as quote

Returns:

  • (Boolean)


26
27
28
# File 'lib/mail_extract/line.rb', line 26

def quote?
  type == :quote
end

#signature?Boolean

Returns true if line was detected as signature

Returns:

  • (Boolean)


32
33
34
# File 'lib/mail_extract/line.rb', line 32

def signature?
  type == :signature
end

#text?Boolean

Returns true if line was detected as text

Returns:

  • (Boolean)


20
21
22
# File 'lib/mail_extract/line.rb', line 20

def text?
  type == :text
end