Class: MyPipe

Inherits:
Object
  • Object
show all
Defined in:
lib/rest_debug/pipes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pipe) ⇒ MyPipe

Returns a new instance of MyPipe.



24
25
26
# File 'lib/rest_debug/pipes.rb', line 24

def initialize(pipe)
  @pipe = pipe
end

Instance Attribute Details

#pipeObject

Returns the value of attribute pipe.



23
24
25
# File 'lib/rest_debug/pipes.rb', line 23

def pipe
  @pipe
end

Instance Method Details

#closeObject



52
53
54
55
# File 'lib/rest_debug/pipes.rb', line 52

def close
  read
  pipe.close
end

#closed?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/rest_debug/pipes.rb', line 35

def closed?
  read_cache =~ /#{done_str}/
end

#open?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/rest_debug/pipes.rb', line 38

def open?
  !closed?
end

#pidObject



56
57
58
# File 'lib/rest_debug/pipes.rb', line 56

def pid
  pipe.pid
end

#readObject



30
31
32
33
34
# File 'lib/rest_debug/pipes.rb', line 30

def read
  res = pipe.read_available
  self.read_cache << res
  res.gsub(done_str,"")
end

#read_allObject



42
43
44
45
46
47
# File 'lib/rest_debug/pipes.rb', line 42

def read_all
  read
  res = read_cache
  res << "\n(CLOSED)" if closed?
  res
end

#write(*args) ⇒ Object



49
50
51
# File 'lib/rest_debug/pipes.rb', line 49

def write(*args)
  pipe.write(*args)
end