Module: Klam::Primitives::Streams
- Included in:
- Environment
- Defined in:
- lib/klam/primitives/streams.rb
Instance Method Summary collapse
- #close(stream) ⇒ Object
- #open(name, direction) ⇒ Object
- #read_byte(stream) ⇒ Object (also: #read-byte)
- #write_byte(byte, stream) ⇒ Object (also: #write-byte)
Instance Method Details
#close(stream) ⇒ Object
26 27 28 29 |
# File 'lib/klam/primitives/streams.rb', line 26 def close(stream) stream.close :NIL end |
#open(name, direction) ⇒ Object
21 22 23 24 |
# File 'lib/klam/primitives/streams.rb', line 21 def open(name, direction) ::File.open(::File.(name, value(:'*home-directory*')), direction == :out ? 'w' : 'r') end |
#read_byte(stream) ⇒ Object Also known as: read-byte
4 5 6 7 8 9 10 |
# File 'lib/klam/primitives/streams.rb', line 4 def read_byte(stream) if stream.eof? -1 else stream.readbyte end end |
#write_byte(byte, stream) ⇒ Object Also known as: write-byte
14 15 16 17 |
# File 'lib/klam/primitives/streams.rb', line 14 def write_byte(byte, stream) stream.putc byte byte end |