Class: EOL::Client
- Inherits:
-
Object
- Object
- EOL::Client
- Defined in:
- lib/eol_rb/client.rb
Overview
HTTP client for endoflife.date API
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the value of attribute http.
Instance Method Summary collapse
- #get(endpoint) ⇒ Object
-
#initialize(http = nil) ⇒ Client
constructor
A new instance of Client.
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
#http ⇒ Object (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 |