Class: Log::Analyzer::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/log-analyzer/endpoint.rb

Defined Under Namespace

Classes: Value

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method: "", uri_pattern: "") ⇒ Endpoint

Returns a new instance of Endpoint.



5
6
7
8
9
10
# File 'lib/log-analyzer/endpoint.rb', line 5

def initialize(method: "", uri_pattern: "")
  @method      = method
  @uri_pattern = uri_pattern
  @count       = 0
  @values      = {}
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



3
4
5
# File 'lib/log-analyzer/endpoint.rb', line 3

def count
  @count
end

#methodObject

Returns the value of attribute method.



3
4
5
# File 'lib/log-analyzer/endpoint.rb', line 3

def method
  @method
end

#uri_patternObject

Returns the value of attribute uri_pattern.



3
4
5
# File 'lib/log-analyzer/endpoint.rb', line 3

def uri_pattern
  @uri_pattern
end

#valuesObject

Returns the value of attribute values.



3
4
5
# File 'lib/log-analyzer/endpoint.rb', line 3

def values
  @values
end

Class Method Details

.allObject



24
25
26
# File 'lib/log-analyzer/endpoint.rb', line 24

def self.all
  self.endpoints.values
end

.create(method: "", uri_pattern: "") ⇒ Object



16
17
18
# File 'lib/log-analyzer/endpoint.rb', line 16

def self.create(method: "", uri_pattern: "")
  endpoints["#{method}:#{uri_pattern}"] = self.new(method: method, uri_pattern: uri_pattern)
end

.endpointsObject



28
29
30
# File 'lib/log-analyzer/endpoint.rb', line 28

def self.endpoints
  @endpoints ||= {}
end

.find_by(method: "", uri_pattern: "") ⇒ Object



20
21
22
# File 'lib/log-analyzer/endpoint.rb', line 20

def self.find_by(method: "", uri_pattern: "")
  endpoints["#{method}:#{uri_pattern}"]
end

Instance Method Details

#[](key) ⇒ Object



12
13
14
# File 'lib/log-analyzer/endpoint.rb', line 12

def [](key)
  @values[key] ||= Value.new
end