Class: EventMachine::Http::MonitorFactory::FileOutputter

Inherits:
Object
  • Object
show all
Defined in:
lib/em-http-monitor.rb

Direct Known Subclasses

MockingFileOutputter

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ FileOutputter

Returns a new instance of FileOutputter.



167
168
169
170
171
# File 'lib/em-http-monitor.rb', line 167

def initialize(file)
  @file = file
  @fh = File.new(file, 'a')
  @fh.sync = true
end

Instance Method Details

#receive(client, data) ⇒ Object



183
184
185
186
187
# File 'lib/em-http-monitor.rb', line 183

def receive(client, data)
  @fh.puts({:mode => 'receive', :id => client.object_id, :data => data}.to_json)
  @fh.fsync
  true
end

#resetObject



173
174
175
# File 'lib/em-http-monitor.rb', line 173

def reset
  File.truncate(@file, 0)
end

#send(client, data) ⇒ Object



177
178
179
180
181
# File 'lib/em-http-monitor.rb', line 177

def send(client, data)
  @fh.puts({:mode => 'send', :id => client.object_id, :data => data}.to_json)
  @fh.fsync
  true
end