2009/2/15 Tanaka Akira <akr / fsij.org>:
> In article <a5d587fb0902141711q780f0d24jef9be9b8bbe69b2a / mail.gmail.com>,
>  Michal Suchanek <hramrach / centrum.cz> writes:
>
>>> For example, zip code or some fixed numbering system is
>>> fixed length but multibyte encoding is not useful.
>>
>> Let's make it more general - what about the first N characters or first N lines?
>>
>> I'm sure you can understand this is useful.
>
> I think I don't understand the usefulness until an actual
> example is shown.
>
>> If a method like head(N) was implemented on it would it leave the IO
>> pointing to the text after the first N records, be it chars, lines, or
>> anything else?
>
> What is represented by the N chars?

I don't understand the question. N chars are N chars, they do not
represent anything else.

It's actually not that hard except the synchronization is not perfect.
By using chars and then lines I lost "F"

irb(main):001:0> f=File.open "rom.asm"
=> #<File:rom.asm>
irb(main):002:0> f.chars.take(10)
=> ["0", "0", "0", "0", "0", "0", "0", "0", " ", " "]
irb(main):003:0> f.lines.take(3)
=> ["A                cli\n", "00000001  FC                cld\n",
"00000002  66670F0115000000  o32 lgdt [dword 0x0]\n"]
irb(main):004:0> f.seek(0)
=> 0
irb(main):005:0> f.lines.take(1)
=> ["00000000  FA                cli\n"]

Thanks

Michal