Class: ReadMailState
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Messages
#go_ahead, #goodbye, #greeting, #helo_response, #ok
Constructor Details
#initialize(protocol = nil) ⇒ ReadMailState
78
79
80
|
# File 'lib/smtp_states.rb', line 78
def initialize(protocol = nil)
@protocol = protocol
end
|
Instance Attribute Details
#protocol ⇒ Object
Returns the value of attribute protocol.
75
76
77
|
# File 'lib/smtp_states.rb', line 75
def protocol
@protocol
end
|
Instance Method Details
#not_end_of_message(line) ⇒ Object
102
103
104
|
# File 'lib/smtp_states.rb', line 102
def not_end_of_message(line)
not line.strip.eql?('.')
end
|
#read_message(io) ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/smtp_states.rb', line 90
def read_message(io)
message = ''
line = io.readline
while not_end_of_message(line)
message << line
line = io.readline
end
message
end
|
#serve(io) ⇒ Object
82
83
84
85
86
87
88
|
# File 'lib/smtp_states.rb', line 82
def serve(io)
message = read_message(io)
@protocol.new_message_received(message)
ok(io)
:quit
end
|