1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: RMail::Mailbox::MBoxReader</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel=StyleSheet href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript" language="JavaScript">
<!--
function popCode(url) {
window.open(url, "Code",
"resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
//-->
</script>
</head>
<body bgcolor="white">
<table summary="Information on class" width="100%" border="0" cellspacing="0">
<tr class="title-row">
<td class="big-title-font">
<sup><font color="aqua">Class</font></sup> RMail::Mailbox::MBoxReader
</td>
<td align="right">
<table summary="layout" cellspacing="0" cellpadding="2">
<tr valign="top">
<td class="small-title-font">In:</td>
<td class="small-title-font">
<a href="../../../files/lib/rmail/mailbox/mboxreader_rb.html" class="aqua">
lib/rmail/mailbox/mboxreader.rb
</a>
<br />
</td>
</tr>
<tr>
<td class="small-title-font">Parent:</td>
<td class="small-title-font">
RMail::Parser::PushbackReader
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- banner header -->
<div class="description"><p>
Class that can parse Unix mbox style mailboxes. These mailboxes separate
individual messages with a line beginning with the string "From
".
</p>
<p>
Typical usage:
</p>
<pre>
File.open("file.mbox") { |file|
RMail::Mailbox::MBoxReader.new(file).each_message { |input|
message = RMail::Parser.read(input)
# do something with the message
end
}
</pre>
<p>
Or see <a href="../Mailbox.html">RMail::Mailbox</a>.<a
href="../Mailbox.html#M000001">parse_mbox</a> for a more convenient
interface.
</p>
</div>
<table summary="Methods" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Methods</td></tr>
</table>
<div class="name-list">
<a href="#M000006">each_message</a>
<a href="#M000005">eof</a>
<a href="#M000002">new</a>
<a href="#M000004">next</a>
<a href="#M000003">read_chunk</a>
</div>
<table summary="Method list" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Public Class methods</td></tr>
</table>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000002"></a>
<a href="MBoxReader.src/M000002.html" target="Code" class="methodtitle"
onClick="popCode('MBoxReader.src/M000002.html');return false;">
<b>new</b>(input, line_separator = $/)
</a>
</td></tr>
</table>
<div class="description">
<p>
Creates a new <a href="MBoxReader.html">MBoxReader</a> that reads from
`input’ with lines that end with `line_separator’.
</p>
<p>
`input’ can either be an IO source (an object that responds to the
"read" method in the same way as a standard IO object) or a
String.
</p>
<p>
`line_separator’ defaults to $/, and useful values are probably
limited to "\n" (Unix) and "\r\n" (DOS/Windows).
</p>
</div>
<table summary="Method list" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Public Instance methods</td></tr>
</table>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000003"></a>
<a href="MBoxReader.src/M000003.html" target="Code" class="methodtitle"
onClick="popCode('MBoxReader.src/M000003.html');return false;">
<b>read_chunk</b>(size)
</a>
</td></tr>
</table>
<div class="description">
<p>
Reads some data from the current message and returns it. The `size’
argument is just a suggestion, and the returned string can be larger or
smaller. When `size’ is nil, then the entire message is returned.
</p>
<p>
Once all data from the current message has been read, <a
href="../Parser.html#M000025">#read</a> returns nil and <a
href="MBoxReader.html#M000004">#next</a> must be called to begin reading
from the next message. You can use <a
href="MBoxReader.html#M000005">#eof</a> to tell if there is any more data
to be read from the input source.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000004"></a>
<a href="MBoxReader.src/M000004.html" target="Code" class="methodtitle"
onClick="popCode('MBoxReader.src/M000004.html');return false;">
<b>next</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Advances to the next message to be read. Call this after <a
href="../Parser.html#M000025">#read</a> returns nil.
</p>
<p>
Note: Once <a href="../Parser.html#M000025">#read</a> returns nil, you can
call <a href="MBoxReader.html#M000005">#eof</a> before or after calling <a
href="MBoxReader.html#M000004">#next</a> to tell if there actually is a
next message to read.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000005"></a>
<a href="MBoxReader.src/M000005.html" target="Code" class="methodtitle"
onClick="popCode('MBoxReader.src/M000005.html');return false;">
<b>eof</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Returns true if the next call to <a
href="MBoxReader.html#M000003">read_chunk</a> will return nil.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000006"></a>
<a href="MBoxReader.src/M000006.html" target="Code" class="methodtitle"
onClick="popCode('MBoxReader.src/M000006.html');return false;">
<b>each_message</b>() {|self| ...}
</a>
</td></tr>
</table>
<div class="description">
<p>
Yield self until eof, calling next after each yield.
</p>
<p>
This method makes it simple to read messages successively out of the
mailbox. See the class description for a code example.
</p>
</div>
</body>
</html>
|