Sha256: 3e794154ee65ae8eb1dddf92ffaf3252f117175efd27014021aac2e0b0c707e4

Contents?: true

Size: 1.55 KB

Versions: 89

Compression:

Stored size: 1.55 KB

Contents

# Copyright (C) 2014  Ruby-GNOME2 Project Team
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

module Gio
  class InputStream
    alias_method :read_raw, :read
    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_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

    private
    def read_raw_compatible(buffer)
      if (GLib::VERSION <=> [2, 36, 0]) >= 0
        read_raw(buffer)
      else
        read_raw(buffer, buffer.bytesize)
      end
    end
  end
end

Version data entries

89 entries across 81 versions & 2 rubygems

Version Path
savant-echo-0.1.5 bin/alexa-0.1.2-osx/lib/vendor/ruby/2.2.0/gems/gio2-3.1.0/lib/gio2/input-stream.rb
savant-echo-0.1.4 bin/alexa-0.1.2-osx/lib/vendor/ruby/2.2.0/gems/gio2-3.1.0/lib/gio2/input-stream.rb
savant-echo-0.1.4 bin/packaging/vendor/ruby/2.2.0/gems/gio2-3.1.0/lib/gio2/input-stream.rb
savant-echo-0.1.3 bin/packaging/vendor/ruby/2.2.0/gems/gio2-3.1.0/lib/gio2/input-stream.rb
savant-echo-0.1.3 bin/alexa-0.1.2-osx/lib/vendor/ruby/2.2.0/gems/gio2-3.1.0/lib/gio2/input-stream.rb
gio2-3.1.0-x64-mingw32 lib/gio2/input-stream.rb
gio2-3.1.0-x86-mingw32 lib/gio2/input-stream.rb
gio2-3.1.0 lib/gio2/input-stream.rb
gio2-3.0.9-x64-mingw32 lib/gio2/input-stream.rb
gio2-3.0.9-x86-mingw32 lib/gio2/input-stream.rb
gio2-3.0.9 lib/gio2/input-stream.rb
gio2-3.0.8-x86-mingw32 lib/gio2/input-stream.rb
gio2-3.0.8-x64-mingw32 lib/gio2/input-stream.rb
gio2-3.0.8 lib/gio2/input-stream.rb
gio2-3.0.7-x86-mingw32 lib/gio2/input-stream.rb
gio2-3.0.7-x64-mingw32 lib/gio2/input-stream.rb
gio2-3.0.7 lib/gio2/input-stream.rb
gio2-3.0.6-x64-mingw32 lib/gio2/input-stream.rb
gio2-3.0.6-x86-mingw32 lib/gio2/input-stream.rb
gio2-3.0.6 lib/gio2/input-stream.rb