Class: PatternPark::FCSHProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/airake/fcshd.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, path) ⇒ FCSHProcess

Returns a new instance of FCSHProcess.



117
118
119
120
121
122
123
124
# File 'lib/airake/fcshd.rb', line 117

def initialize(target, path)
  @target = target
  @path = path
  start = Dir.pwd
  Dir.chdir(path)
  @w, @r, @e = Open3.popen3(target)
  Dir.chdir(start)
end

Instance Attribute Details

#eObject (readonly)

Returns the value of attribute e.



115
116
117
# File 'lib/airake/fcshd.rb', line 115

def e
  @e
end

#pathObject (readonly)

Returns the value of attribute path.



115
116
117
# File 'lib/airake/fcshd.rb', line 115

def path
  @path
end

#rObject (readonly)

Returns the value of attribute r.



115
116
117
# File 'lib/airake/fcshd.rb', line 115

def r
  @r
end

#wObject (readonly)

Returns the value of attribute w.



115
116
117
# File 'lib/airake/fcshd.rb', line 115

def w
  @w
end

Instance Method Details

#puts(msg) ⇒ Object



126
127
128
# File 'lib/airake/fcshd.rb', line 126

def puts(msg)
  @w.puts(msg)
end

#readObject



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/airake/fcshd.rb', line 130

def read
  line = ''
  response = ''
  while(!r.eof?)
    char = r.getc.chr
    line += char
    if (line == '(fcsh)')
      response += "[PROMPT] #{line}"
      break
    end
    if (char == "\n")
      response += "[FCSH] #{line}"
      line = ''
    end
  end
  return response
end