Class: Gio::InputStream
- Inherits:
-
Object
- Object
- Gio::InputStream
- Defined in:
- lib/gio2/input-stream.rb
Instance Method Summary collapse
Instance Method Details
#read(size = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gio2/input-stream.rb', line 20 def read(size=nil) if size.nil? all = "".force_encoding("ASCII-8BIT") buffer_size = 8192 buffer = " ".force_encoding("ASCII-8BIT") * buffer_size loop do _, read_bytes = read_all_raw_compatible(buffer) all << buffer.byteslice(0, read_bytes) break if read_bytes != buffer_size end all else buffer = " " * size read_bytes = read_raw_compatible(buffer) buffer.replace(buffer.byteslice(0, read_bytes)) buffer end end |
#read_all(size) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/gio2/input-stream.rb', line 40 def read_all(size) buffer = " " * size _, read_bytes = read_all_raw_compatible(buffer) buffer.replace(buffer.byteslice(0, read_bytes)) buffer end |
#read_all_raw ⇒ Object
39 |
# File 'lib/gio2/input-stream.rb', line 39 alias_method :read_all_raw, :read_all |
#read_raw ⇒ Object
19 |
# File 'lib/gio2/input-stream.rb', line 19 alias_method :read_raw, :read |