Class: Mail
Class Method Summary collapse
Instance Method Summary collapse
- #body ⇒ Object
- #header ⇒ Object
-
#initialize(f) ⇒ Mail
constructor
A new instance of Mail.
Constructor Details
#initialize(f) ⇒ Mail
Returns a new instance of Mail.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'sample/tkfrom.rb', line 21 def initialize(f) @header = {} @body = [] while line = f.gets() $_.chop! next if /^From / =~ line # skip From-line break if /^$/ =~ line # end of header if /^(\S+):\s*(.*)/ =~ line @header[attr = $1.capitalize] = $2 elsif attr sub(/^\s*/, '') @header[attr] += "\n" + $_ end end return unless $_ while line = f.gets() break if /^From / =~ line @body.push($_) end end |