Module: SimpleAdvice

Defined in:
lib/simple_advice.rb,
lib/simple_advice/error.rb,
lib/simple_advice/client.rb,
lib/simple_advice/config.rb,
lib/simple_advice/object.rb,
lib/simple_advice/version.rb,
lib/simple_advice/collection.rb,
lib/simple_advice/objects/advice.rb

Defined Under Namespace

Classes: Advice, Client, Collection, Config, Error, Object

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.find(advice_id:) ⇒ Object



24
25
26
27
# File 'lib/simple_advice.rb', line 24

def find(advice_id:)
  advice_obj = JSON.parse(Client.get_request("advice/#{advice_id}").body)["slip"]
  advice_obj ? Advice.new(advice_obj) : nil
end

.find_by(query:) ⇒ Object



29
30
31
# File 'lib/simple_advice.rb', line 29

def find_by(query:)
  Collection.from_response(Client.get_request("advice/search/#{query}"), key: "slips", type: Advice)
end

.randomObject



20
21
22
# File 'lib/simple_advice.rb', line 20

def random
  Advice.new JSON.parse(Client.get_request("advice").body)["slip"]
end