Class: DoroParser::Parser::SMTP

Inherits:
Object
  • Object
show all
Defined in:
lib/dorothy2/DEM.rb

Overview

todo to redo ##NEW PARSER CODED BY SALVATORE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(a) ⇒ SMTP

Returns a new instance of SMTP.



90
91
92
93
94
95
# File 'lib/dorothy2/DEM.rb', line 90

def initialize a
  if a =~ /(MAIL FROM: |EHLO |HELO |TO: |RSET)(.*)\n/
    @hcmd = $1
    @hcont = $2
  end
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



60
61
62
# File 'lib/dorothy2/DEM.rb', line 60

def body
  @body
end

#hcmdObject (readonly)

Returns the value of attribute hcmd.



58
59
60
# File 'lib/dorothy2/DEM.rb', line 58

def hcmd
  @hcmd
end

#hcontObject (readonly)

Returns the value of attribute hcont.



59
60
61
# File 'lib/dorothy2/DEM.rb', line 59

def hcont
  @hcont
end

#rdataObject

Returns the value of attribute rdata.



61
62
63
# File 'lib/dorothy2/DEM.rb', line 61

def rdata
  @rdata
end

Class Method Details

.body(data) ⇒ Object



65
66
67
68
# File 'lib/dorothy2/DEM.rb', line 65

def self.body(data)
  email = TMail::Mail.parse(data)
  return email
end

.hasbody?(data) ⇒ Boolean

Returns:

  • (Boolean)


76
77
78
79
80
# File 'lib/dorothy2/DEM.rb', line 76

def self.hasbody?(data)
  if data =~ /from(.*)From(.*)Subject/m
    return true
  end
end

.header?(data) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
73
74
# File 'lib/dorothy2/DEM.rb', line 70

def self.header?(data)
  if data =~ /(MAIL FROM: |EHLO |HELO |TO: |RSET)(.*)\n/
    return true
  end
end

.response(data) ⇒ Object



82
83
84
85
86
87
88
# File 'lib/dorothy2/DEM.rb', line 82

def self.response(data)
  if data =~ /(\d*)(.*)\n/
    rcode = $1
    rcont = $2
    return rcode, rcont
  end
end