class Reader
class Reader
lib/io/reader.tya:2
Reader provides the io/Reader standard library API.
Source
# Reader provides the io/Reader standard library API.
class Reader implements Readable, Closable
# Reader.binary stores instance state.
# @type Nil
binary: nil
# Reader.handle stores instance state.
# @type Nil
handle: nil
# Reader.initialize provides the io/Reader standard library operation.
# @param handle Any handle value.
# @param binary Boolean binary value.
# @return Self the initialized object.
initialize: handle, binary ->
self.handle = handle
self.binary = binary
# Reader.close provides the io/Reader standard library operation.
# @return Nil the resulting value.
close: ->
io_stream_close(self.handle)
# Reader.each_line provides the io/Reader standard library operation.
# @param fn Function fn value.
# @return Any the resulting value.
each_line: fn ->
line = self.read_line()
while line != nil
fn(line)
line = self.read_line()
nil
# Reader.eof? provides the io/Reader standard library operation.
# @return Boolean whether the condition is true.
eof?: ->
io_stream_eof(self.handle)
# Reader.read provides the io/Reader standard library operation.
# @param size Int size value.
# @return Any the resulting value.
read: size ->
io_stream_read(self.handle, size)
# Reader.read_line provides the io/Reader standard library operation.
# @return String the resulting value.
read_line: ->
io_stream_read_line(self.handle)
Instance Variables
binary
Reader.binary
lib/io/reader.tya:5
Reader.binary stores instance state.
Source
# Reader.binary stores instance state.
# @type Nil
binary: nil
handle
Reader.handle
lib/io/reader.tya:9
Reader.handle stores instance state.
Source
# Reader.handle stores instance state.
# @type Nil
handle: nil
Methods
close
Reader.close()
lib/io/reader.tya:21
Reader.close provides the io/Reader standard library operation.
Source
# Reader.close provides the io/Reader standard library operation.
# @return Nil the resulting value.
close: ->
io_stream_close(self.handle)
each_line
Reader.each_line(fn)
lib/io/reader.tya:27
Reader.each_line provides the io/Reader standard library operation.
Source
# Reader.each_line provides the io/Reader standard library operation.
# @param fn Function fn value.
# @return Any the resulting value.
each_line: fn ->
line = self.read_line()
while line != nil
fn(line)
line = self.read_line()
nil
eof?
Reader.eof?()
lib/io/reader.tya:36
Reader.eof? provides the io/Reader standard library operation.
Source
# Reader.eof? provides the io/Reader standard library operation.
# @return Boolean whether the condition is true.
eof?: ->
io_stream_eof(self.handle)
initialize
Reader.initialize(handle, binary)
lib/io/reader.tya:15
Reader.initialize provides the io/Reader standard library operation.
Source
# Reader.initialize provides the io/Reader standard library operation.
# @param handle Any handle value.
# @param binary Boolean binary value.
# @return Self the initialized object.
initialize: handle, binary ->
self.handle = handle
self.binary = binary
read
Reader.read(size)
lib/io/reader.tya:42
Reader.read provides the io/Reader standard library operation.
Source
# Reader.read provides the io/Reader standard library operation.
# @param size Int size value.
# @return Any the resulting value.
read: size ->
io_stream_read(self.handle, size)
read_line
Reader.read_line()
lib/io/reader.tya:47
Reader.read_line provides the io/Reader standard library operation.
Source
# Reader.read_line provides the io/Reader standard library operation.
# @return String the resulting value.
read_line: ->
io_stream_read_line(self.handle)