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,
  /^sent from my (iphone|ipad)/i => :signature 
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ Line

Returns a new instance of Line.



14
15
16
17
18
19
# File 'lib/mail_extract/line.rb', line 14

def initialize(str)
  @body    = str
  @subtype = :none
  
  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

#subtypeObject (readonly)

Returns the value of attribute subtype.



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

def subtype
  @subtype
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)


29
30
31
# File 'lib/mail_extract/line.rb', line 29

def quote?
  type == :quote
end

#signature?Boolean

Returns true if line was detected as signature

Returns:

  • (Boolean)


35
36
37
# File 'lib/mail_extract/line.rb', line 35

def signature?
  type == :signature
end

#text?Boolean

Returns true if line was detected as text

Returns:

  • (Boolean)


23
24
25
# File 'lib/mail_extract/line.rb', line 23

def text?
  type == :text
end