Created
December 21, 2013 14:49
-
-
Save akiray03/8070300 to your computer and use it in GitHub Desktop.
mruby-ioのつくりかた ref: http://qiita.com/akiray03/items/d6f29db921ff680bc699
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class IO | |
| def write(string) | |
| str = string.is_a?(String) ? string : string.to_s | |
| return str.size unless str.size > 0 | |
| len = syswrite(str) | |
| if str.size == len | |
| @pos += len | |
| return len | |
| end | |
| raise IOError | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class IO | |
| def _read_buf | |
| return @buf if @buf && @buf.size > 0 | |
| @buf = sysread(BUF_SIZE) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment