summaryrefslogtreecommitdiffstats
path: root/lib/mailread.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-04 22:00:31 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-04 22:00:31 +0000
commit143f8a86a46b7ec38ad5382b8fe00e80785c1212 (patch)
tree3ebfb81d7fdc03904604b2c7148180d7c6b02cec /lib/mailread.rb
parentaf5d40cde2072fbe74e2d5017cc9fa147c0b7d24 (diff)
downloadruby-143f8a86a46b7ec38ad5382b8fe00e80785c1212.tar.gz
ruby-143f8a86a46b7ec38ad5382b8fe00e80785c1212.tar.xz
ruby-143f8a86a46b7ec38ad5382b8fe00e80785c1212.zip
Merge RDoc changes from HEAD.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@10679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/mailread.rb')
-rw-r--r--lib/mailread.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/mailread.rb b/lib/mailread.rb
index 7573d03ed..08b33c92a 100644
--- a/lib/mailread.rb
+++ b/lib/mailread.rb
@@ -1,5 +1,14 @@
+# 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")
@@ -34,14 +43,19 @@ class Mail
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