Class: Smartware::Driver::Modem::Standard::LogConnection
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- Smartware::Driver::Modem::Standard::LogConnection
- Includes:
- EventMachine::Protocols::LineProtocol
- Defined in:
- lib/smartware/drivers/modem/standard.rb
Instance Method Summary collapse
-
#initialize(device) ⇒ LogConnection
constructor
A new instance of LogConnection.
- #receive_line(line) ⇒ Object
Constructor Details
#initialize(device) ⇒ LogConnection
Returns a new instance of LogConnection.
12 13 14 |
# File 'lib/smartware/drivers/modem/standard.rb', line 12 def initialize(device) @device = device end |
Instance Method Details
#receive_line(line) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/smartware/drivers/modem/standard.rb', line 16 def receive_line(line) line.rstrip! Logging.logger.debug "pppd: #{line}" case line when /^remote IP address/ @started = Time.now.to_i when /^Sent ([0-9]+) bytes, received ([0-9]+) bytes.$/ @sent = $1.to_i @received = $2.to_i when /^Connect time ([0-9.]+) minutes.$/ @time = ($1.to_f * 60).round when "Connection terminated." begin @device.account.call @started, @sent, @received, @time ensure @started = nil @sent = nil @received = nil @time = nil end end end |