summaryrefslogtreecommitdiff
path: root/ruby_1_8_6/lib/mailread.rb
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-07 07:38:25 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-07 07:38:25 +0000
commit9ff1e787f915539b1980654e3d3d2013ff5c81d2 (patch)
tree8d0fc9ca5b4dbfa9885dc56862292d55091bcaac /ruby_1_8_6/lib/mailread.rb
parent441546edcfbb1b346c87b69c5f578d1a0e522e06 (diff)
wrong commit; sorryv1_8_6_269
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_6_269@17938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby_1_8_6/lib/mailread.rb')
-rw-r--r--ruby_1_8_6/lib/mailread.rb62
1 files changed, 0 insertions, 62 deletions
diff --git a/ruby_1_8_6/lib/mailread.rb b/ruby_1_8_6/lib/mailread.rb
deleted file mode 100644
index 08b33c92a4..0000000000
--- a/ruby_1_8_6/lib/mailread.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-# The Mail class represents an internet mail message (as per RFC822, RFC2822)
-# with headers and a body.
-class Mail
-
- # Create a new Mail where +f+ is either a stream which responds to gets(),
- # or a path to a file. If +f+ is a path it will be opened.
- #
- # The whole message is read so it can be made available through the #header,
- # #[] and #body methods.
- #
- # The "From " line is ignored if the mail is in mbox format.
- def initialize(f)
- unless defined? f.gets
- f = open(f, "r")
- opened = true
- end
-
- @header = {}
- @body = []
- begin
- while line = f.gets()
- line.chop!
- next if /^From /=~line # skip From-line
- break if /^$/=~line # end of header
-
- if /^(\S+?):\s*(.*)/=~line
- (attr = $1).capitalize!
- @header[attr] = $2
- elsif attr
- line.sub!(/^\s*/, '')
- @header[attr] += "\n" + line
- end
- end
-
- return unless line
-
- while line = f.gets()
- break if /^From /=~line
- @body.push(line)
- end
- ensure
- f.close if opened
- end
- end
-
- # Return the headers as a Hash.
- def header
- return @header
- end
-
- # Return the message body as an Array of lines
- def body
- return @body
- end
-
- # Return the header corresponding to +field+.
- #
- # Matching is case-insensitive.
- def [](field)
- @header[field.capitalize]
- end
-end