Class: ForemLite::Client
- Inherits:
-
Object
- Object
- ForemLite::Client
- Includes:
- HTTParty
- Defined in:
- lib/forem_lite/client.rb
Instance Method Summary collapse
-
#article(id) ⇒ Object
Retrieve a single published article given its id.
-
#articles ⇒ Array<Object>
Retrieve a list of articles.
-
#initialize(api_key = nil) ⇒ Client
constructor
Create a new client object with your Forem API key.
Constructor Details
#initialize(api_key = nil) ⇒ Client
Create a new client object with your Forem API key.
11 12 13 |
# File 'lib/forem_lite/client.rb', line 11 def initialize(api_key = nil) self.class.[:headers] = {"api-key" => api_key} if api_key end |
Instance Method Details
#article(id) ⇒ Object
Retrieve a single published article given its id.
31 32 33 |
# File 'lib/forem_lite/client.rb', line 31 def article(id) ForemLite::Article.new(self.class.get("/articles/#{id}")) end |
#articles ⇒ Array<Object>
Retrieve a list of articles.
20 21 22 |
# File 'lib/forem_lite/client.rb', line 20 def articles self.class.get("/articles").tap { |z| ForemLite::Article.new(z) } end |