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.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'sample/tkbiff.rb', line 38 def initialize(f) @header = {} @body = [] while line = f.gets() line.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 |
Class Method Details
.new(f) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'sample/tkbiff.rb', line 27 def Mail.new(f) if !f.kind_of?(IO) f = open(f, "r") me = super f.close else me = super end return me end |