Class: Fitting::Skip::API

Inherits:
Object
  • Object
show all
Defined in:
lib/fitting/skip/api.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, host, prefix) ⇒ API

Returns a new instance of API.



6
7
8
9
10
# File 'lib/fitting/skip/api.rb', line 6

def initialize(type, host, prefix)
  @type = type
  @host = host
  @prefix = prefix
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



4
5
6
# File 'lib/fitting/skip/api.rb', line 4

def host
  @host
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/fitting/skip/api.rb', line 4

def path
  @path
end

#prefixObject

Returns the value of attribute prefix.



4
5
6
# File 'lib/fitting/skip/api.rb', line 4

def prefix
  @prefix
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/fitting/skip/api.rb', line 4

def type
  @type
end

Class Method Details

.all(apis) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/fitting/skip/api.rb', line 12

def self.all(apis)
  return [] unless apis
  apis.map do |api|
    next if api['method'] || api['path']
    new('provided', api['host'], api['prefix'])
  end.compact
end

.find(apis, log) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/fitting/skip/api.rb', line 20

def self.find(apis, log)
  apis.find do |api|
    if log.host == api.host
      api.prefix.nil? || api.prefix == '' || log.path[0..api.prefix.size - 1] == api.prefix
    end
  end
end