Class: Haproxy2Rpm::LineParser

Inherits:
Object
  • Object
show all
Defined in:
lib/haproxy2rpm/line_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ LineParser

Returns a new instance of LineParser.



4
5
6
# File 'lib/haproxy2rpm/line_parser.rb', line 4

def initialize(line)
  @parts = line.split("\s")
end

Instance Method Details

#http_methodObject

we need to chop "



33
34
35
# File 'lib/haproxy2rpm/line_parser.rb', line 33

def http_method
  @http_method ||= @parts[12][1..-1]
end

#http_pathObject



41
42
43
# File 'lib/haproxy2rpm/line_parser.rb', line 41

def http_path
  uri.path
end

#http_queryObject



45
46
47
# File 'lib/haproxy2rpm/line_parser.rb', line 45

def http_query
  uri.query
end

#is_error?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/haproxy2rpm/line_parser.rb', line 49

def is_error?
  status_code >= 500
end

#status_codeObject



28
29
30
# File 'lib/haproxy2rpm/line_parser.rb', line 28

def status_code
  @status_code ||= @parts[5].to_i
end

#tcObject



16
17
18
# File 'lib/haproxy2rpm/line_parser.rb', line 16

def tc
  @tc ||= response_times[2].to_i
end

#tqObject



8
9
10
# File 'lib/haproxy2rpm/line_parser.rb', line 8

def tq
  @tw ||= response_times[0].to_i
end

#trObject



20
21
22
# File 'lib/haproxy2rpm/line_parser.rb', line 20

def tr
  @tr ||= response_times[3].to_i
end

#ttObject



24
25
26
# File 'lib/haproxy2rpm/line_parser.rb', line 24

def tt
  @tt ||= response_times[4].to_i
end

#twObject



12
13
14
# File 'lib/haproxy2rpm/line_parser.rb', line 12

def tw
  @tw ||= response_times[1].to_i
end

#uriObject



37
38
39
# File 'lib/haproxy2rpm/line_parser.rb', line 37

def uri
  @uri ||= URI.parse(@parts[13])
end