Class: EOL::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/eol_rb/client.rb

Overview

HTTP client for endoflife.date API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http = nil) ⇒ Client

Returns a new instance of Client.



12
13
14
15
16
17
18
19
20
# File 'lib/eol_rb/client.rb', line 12

def initialize(http = nil)
  @http = http || Faraday.new(
    url: "#{api.scheme}://#{api.host}",
    headers: {
      "Content-Type" => "application/json",
      "User-Agent" => "endoflife.date Ruby Gem v#{EOL::VERSION}"
    }
  )
end

Instance Attribute Details

#httpObject (readonly)

Returns the value of attribute http.



10
11
12
# File 'lib/eol_rb/client.rb', line 10

def http
  @http
end

Instance Method Details

#get(endpoint) ⇒ Object



22
23
24
# File 'lib/eol_rb/client.rb', line 22

def get(endpoint)
  @http.get("#{api.path}/#{endpoint}")
end