Class: Malm::Message
- Inherits:
-
Object
- Object
- Malm::Message
- Defined in:
- lib/malm/message.rb
Instance Attribute Summary collapse
-
#email_body ⇒ Object
readonly
Returns the value of attribute email_body.
-
#mail_from ⇒ Object
readonly
Returns the value of attribute mail_from.
-
#rcpt_to ⇒ Object
readonly
Returns the value of attribute rcpt_to.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
-
#initialize ⇒ Message
constructor
A new instance of Message.
- #process_line(line = nil) ⇒ Object
- #subject ⇒ Object
Constructor Details
#initialize ⇒ Message
Returns a new instance of Message.
5 6 7 8 9 |
# File 'lib/malm/message.rb', line 5 def initialize @email_body = "" @rcpt_to = [] @state = :init_state end |
Instance Attribute Details
#email_body ⇒ Object (readonly)
Returns the value of attribute email_body.
3 4 5 |
# File 'lib/malm/message.rb', line 3 def email_body @email_body end |
#mail_from ⇒ Object (readonly)
Returns the value of attribute mail_from.
3 4 5 |
# File 'lib/malm/message.rb', line 3 def mail_from @mail_from end |
#rcpt_to ⇒ Object (readonly)
Returns the value of attribute rcpt_to.
3 4 5 |
# File 'lib/malm/message.rb', line 3 def rcpt_to @rcpt_to end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
3 4 5 |
# File 'lib/malm/message.rb', line 3 def state @state end |
Instance Method Details
#process_line(line = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/malm/message.rb', line 11 def process_line(line=nil) if line =~ /QUIT/ return quit! end # state machine pattern. Delegate to state handler for where we're at in SMTP conversation response = send(@state, line) return error! unless response # transition if state handler returned a new state new_state = response.delete(:state) @state = new_state if new_state response end |
#subject ⇒ Object
27 28 29 30 31 |
# File 'lib/malm/message.rb', line 27 def subject if @email_body =~ /^Subject\: (.+)$/ $1.strip end end |