Class: Spx::LogParser
- Inherits:
-
Object
- Object
- Spx::LogParser
- Defined in:
- lib/spx/log_parser.rb
Instance Method Summary collapse
-
#initialize(log_file_path) ⇒ LogParser
constructor
A new instance of LogParser.
- #parse ⇒ Object
Constructor Details
#initialize(log_file_path) ⇒ LogParser
Returns a new instance of LogParser.
5 6 7 |
# File 'lib/spx/log_parser.rb', line 5 def initialize(log_file_path) @log_file_path = log_file_path end |
Instance Method Details
#parse ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/spx/log_parser.rb', line 9 def parse port = nil token = nil File.foreach(@log_file_path) do |line| token ||= line[/Token:\s+(-?\d+)/, 1]&.to_i port ||= line[/:server_port=>(\d+)/, 1]&.to_i break if port && token end { port: port, token: token } end |