Class: Protocol::HTTP::Header::ServerTiming::Metric

Inherits:
Struct
  • Object
show all
Defined in:
lib/protocol/http/header/server_timing.rb

Overview

A single metric in the Server-Timing header.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, duration = nil, description = nil) ⇒ Metric

Create a new server timing metric.



39
40
41
# File 'lib/protocol/http/header/server_timing.rb', line 39

def initialize(name, duration = nil, description = nil)
  super(name, duration, description)
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description



33
34
35
# File 'lib/protocol/http/header/server_timing.rb', line 33

def description
  @description
end

#durationObject

Returns the value of attribute duration



33
34
35
# File 'lib/protocol/http/header/server_timing.rb', line 33

def duration
  @duration
end

#nameObject

Returns the value of attribute name



33
34
35
# File 'lib/protocol/http/header/server_timing.rb', line 33

def name
  @name
end

Instance Method Details

#to_sObject

Convert the metric to its string representation.



46
47
48
49
50
51
# File 'lib/protocol/http/header/server_timing.rb', line 46

def to_s
  result = name.dup
  result << ";dur=#{duration}" if duration
  result << ";desc=\"#{description}\"" if description
  result
end