# module GxG::Support::Library::SocketRW

### Public Instance Methods

<<(*args) click to toggle source

    # File lib/gxg/gxg_io.rb, line 726
    def <<(*args)
      self.write(*args)
      self
    end

each_char(&block) click to toggle source

    # File lib/gxg/gxg_io.rb, line 595
    def each_char(&block)
      unless self.instance_variable_defined?(:@in_buffer)
        @in_buffer = ::StringIO.new("",::IO::RDWR)
        @in_buffer.set_encoding(::Encoding::ASCII_8BIT)
      end
      result = @in_buffer.each_char(&block)
      if @in_buffer.eof?()
        @in_buffer.rewind
        @in_buffer.string.clear
      end
      result
    end

each_line(*args, &block) click to toggle source

    # File lib/gxg/gxg_io.rb, line 608
    def each_line(*args, &block)
      unless self.instance_variable_defined?(:@in_buffer)
        @in_buffer = ::StringIO.new("",::IO::RDWR)
        @in_buffer.set_encoding(::Encoding::ASCII_8BIT)
      end
      result = @in_buffer.each_line(*args, &block)
      if @in_buffer.eof?()
        @in_buffer.rewind
        @in_buffer.string.clear
      end
      result
    end

eof?() click to toggle source

    # File lib/gxg/gxg_io.rb, line 508
    def eof?()
      unless self.instance_variable_defined?(:@in_buffer)
        @in_buffer = ::StringIO.new("",::IO::RDWR)
        @in_buffer.set_encoding(::Encoding::ASCII_8BIT)
      end
      @in_buffer.eof?()
    end

getbyte() click to toggle source

    # File lib/gxg/gxg_io.rb, line 556
    def getbyte()
      unless self.instance_variable_defined?(:@in_buffer)
        @in_buffer = ::StringIO.new("",::IO::RDWR)
        @in_buffer.set_encoding(::Encoding::ASCII_8BIT)
      end
      result = @in_buffer.getbyte()
      if @in_buffer.eof?()
        @in_buffer.rewind
        @in_buffer.string.clear
      end
      result
    end

getc(*args) click to toggle source

    # File lib/gxg/gxg_io.rb, line 569
    def getc(*args)
      unless self.instance_variable_defined?(:@in_buffer)
        @in_buffer = ::StringIO.new("",::IO::RDWR)
        @in_buffer.set_encoding(::Encoding::ASCII_8BIT)
      end
      result = @in_buffer.getc(*args)
      if @in_buffer.eof?()
        @in_buffer.rewind
        @in_buffer.string.clear
      end
      result
    end

gets(*args) click to toggle source

    # File lib/gxg/gxg_io.rb, line 582
    def gets(*args)
      unless self.instance_variable_defined?(:@in_buffer)
        @in_buffer = ::StringIO.new("",::IO::RDWR)
        @in_buffer.set_encoding(::Encoding::ASCII_8BIT)
      end
      result = @in_buffer.gets(*args)
      if @in_buffer.eof?()
        @in_buffer.rewind
        @in_buffer.string.clear
      end
      result
    end

lineno() click to toggle source

    # File lib/gxg/gxg_io.rb, line 532
    def lineno()
      unless self.instance_variable_defined?(:@in_buffer)
        @in_buffer = ::StringIO.new("",::IO::RDWR)
        @in_buffer.set_encoding(::Encoding::ASCII_8BIT)
      end
      @in_buffer.lineno()
    end

lineno=(*args) click to toggle source

    # File lib/gxg/gxg_io.rb, line 540
    def lineno=(*args)
      unless self.instance_variable_defined?(:@in_buffer)
        @in_buffer = ::StringIO.new("",::IO::RDWR)
        @in_buffer.set_encoding(::Encoding::ASCII_8BIT)
      end
      @in_buffer.lineno = args[0]
    end

pos() click to toggle source

    # File lib/gxg/gxg_io.rb, line 516
    def pos()
      unless self.instance_variable_defined?(:@in_buffer)
        @in_buffer = ::StringIO.new("",::IO::RDWR)
        @in_buffer.set_encoding(::Encoding::ASCII_8BIT)
      end
      @in_buffer.pos()
    end

pos=(*args) click to toggle source

    # File lib/gxg/gxg_io.rb, line 524
    def pos=(*args)
      unless self.instance_variable_defined?(:@in_buffer)
        @in_buffer = ::StringIO.new("",::IO::RDWR)
        @in_buffer.set_encoding(::Encoding::ASCII_8BIT)
      end
      @in_buffer.pos = args[0]
    end

read(*args) click to toggle source

    # File lib/gxg/gxg_io.rb, line 621
    def read(*args)
      unless self.instance_variable_defined?(:@in_buffer)
        @in_buffer = ::StringIO.new("",::IO::RDWR)
        @in_buffer.set_encoding(::Encoding::ASCII_8BIT)
      end
      result = @in_buffer.read(*args)
      if @in_buffer.eof?()
        @in_buffer.rewind
        @in_buffer.string.clear
      end
      result
    end

Also aliased as: read_nonblock, sysread
read_nonblock(*args)
Alias for: read
readpartial(*args) click to toggle source

    # File lib/gxg/gxg_io.rb, line 636
    def readpartial(*args)
      #
      if self.closed_read?
        raise IOError, "not open for reading"
      else
        if self.eof?
          raise EOFError, "end of stream reached"
        else
          result = ""
          result.force_encoding(self.internal_encoding)
          data = self.read(*args)
          if data
            # non-nil
            if data.is_a?(::String)
              # 'blocking' or not?
              if (self.eof?() || (data && data.to_s.size > 0))
                # no pseudo-blocking
                result << data
                data = nil
              else
                # pseudo-blocking
                until (self.eof?() || (data && data.to_s.size > 0))
                  data = self.read(*args)
                  # string, buffer, or nil
                  if data
                    #
                    if data.is_a?(::String)
                      if (data && data.to_s.size > 0)
                        result << data
                        data = nil
                        break
                      else
                        if self.eof?()
                          raise EOFError, "end of stream reached"
                        end
                      end
                    else
                      # buffer
                      result = data
                      data = nil
                      break
                    end
                  else
                    if self.eof?()
                      raise EOFError, "end of stream reached"
                    end
                  end
                  #
                  pause
                  #
                end
              end
            else
              # buffer
              result = data
            end
          else
            if self.eof?()
              raise EOFError, "end of stream reached"
            end
          end
          #
          if result
            if result.is_a?(::String)
              if result.bytesize > 0
                result
              else
                nil
              end
            else
              # buffer
              result
            end
          else
            nil
          end
          #
        end
      end
    end

rewind() click to toggle source

    # File lib/gxg/gxg_io.rb, line 548
    def rewind()
      unless self.instance_variable_defined?(:@in_buffer)
        @in_buffer = ::StringIO.new("",::IO::RDWR)
        @in_buffer.set_encoding(::Encoding::ASCII_8BIT)
      end
      @in_buffer.rewind()
    end

sysread(*args)
Alias for: read
syswrite(data="")
Alias for: write
ungetbyte() click to toggle source

    # File lib/gxg/gxg_io.rb, line 731
    def ungetbyte()
      raise NotImplementedError, "unget operations not supported on this type of object"
    end

Also aliased as: ungetbytes, ungetc, ungets
ungetbytes()
Alias for: ungetbyte
ungetc()
Alias for: ungetbyte
ungets()
Alias for: ungetbyte
write(data="") click to toggle source

    # File lib/gxg/gxg_io.rb, line 717
    def write(data="")
      data = self.transcode_to_external(data)
      written_bytes = data.bytesize()
      self.send(data,0)
      written_bytes
    end

Also aliased as: write_nonblock, syswrite
write_nonblock(data="")
Alias for: write