Methods

Public Instance methods

[Source]

    # File expect.rb, line 4
 4:   def expect(pat,timeout=9999999)
 5:     buf = ''
 6:     case pat
 7:     when String
 8:       e_pat = Regexp.new(Regexp.quote(pat))
 9:     when Regexp
10:       e_pat = pat
11:     end
12:     while true
13:       if IO.select([self],nil,nil,timeout).nil? then
14:         result = nil
15:         break
16:       end
17:       c = getc.chr
18:       buf << c
19:       if $expect_verbose
20:         STDOUT.print c
21:         STDOUT.flush
22:       end
23:       if mat=e_pat.match(buf) then
24:         result = [buf,*mat.to_a[1..-1]]
25:         break
26:       end
27:     end
28:     if block_given? then
29:       yield result
30:     else
31:       return result
32:     end
33:     nil
34:   end

[Source]

    # File io/nonblock.rb, line 17
17:   def nonblock(nb = true)
18:     nb, self.nonblock = nonblock?, nb
19:     yield
20:   ensure
21:     self.nonblock = nb
22:   end

[Source]

    # File io/nonblock.rb, line 7
 7:   def nonblock=(nb)
 8:     f = fcntl(Fcntl::F_GETFL)
 9:     if nb
10:       f |= File::NONBLOCK
11:     else
12:       f &= ~File::NONBLOCK
13:     end
14:     fcntl(Fcntl::F_SETFL, f)
15:   end

[Source]

   # File io/nonblock.rb, line 3
3:   def nonblock?
4:     (fcntl(Fcntl::F_GETFL) & File::NONBLOCK) != 0
5:   end

[Source]

    # File readbytes.rb, line 15
15:   def readbytes(n)
16:     str = read(n)
17:     if str == nil
18:       raise EOFError, "End of file reached"
19:     end
20:     if str.size < n
21:       raise TruncatedDataError.new("data truncated", str) 
22:     end
23:     str
24:   end

Search

Google

Ruby API Docs

Links