Class: RazyK::WebApp::InputStream

Inherits:
Object
  • Object
show all
Defined in:
lib/razyk/webapp.rb

Instance Method Summary collapse

Constructor Details

#initialize(str = "") ⇒ InputStream

Returns a new instance of InputStream.



11
12
13
14
# File 'lib/razyk/webapp.rb', line 11

def initialize(str="")
  @buf = str.b
  @chars = []
end

Instance Method Details

#getbyteObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/razyk/webapp.rb', line 15

def getbyte
  if @buf
    ret = @buf.unpack("C")[0]
    @buf = @buf[1..-1]
    if ret
      @chars << ret
    end
    ret
  else
    nil
  end
end

#remainObject



30
31
32
# File 'lib/razyk/webapp.rb', line 30

def remain
  @buf || ""
end

#wroteObject



27
28
29
# File 'lib/razyk/webapp.rb', line 27

def wrote
  @chars.pack("C*")
end