Class: Mtgapi::Client
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #find_by(attr, value) ⇒ Object
- #id_url(id) ⇒ Object
-
#initialize(token = ENV['MTG_TOKEN']) ⇒ Client
constructor
A new instance of Client.
- #name_url(name) ⇒ Object
- #set_url(set) ⇒ Object
- #sets ⇒ Object
- #token_append ⇒ Object
Constructor Details
#initialize(token = ENV['MTG_TOKEN']) ⇒ Client
Returns a new instance of Client.
11 12 13 |
# File 'lib/mtgapi/client.rb', line 11 def initialize(token = ENV['MTG_TOKEN']) @token = token end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
9 10 11 |
# File 'lib/mtgapi/client.rb', line 9 def token @token end |
Instance Method Details
#find_by(attr, value) ⇒ Object
19 20 21 22 |
# File 'lib/mtgapi/client.rb', line 19 def find_by(attr, value) url = self.send("#{attr.to_s}_url", value) self.class.get(url).parsed_response end |
#id_url(id) ⇒ Object
24 25 26 |
# File 'lib/mtgapi/client.rb', line 24 def id_url(id) "/card/id/#{id}" end |
#name_url(name) ⇒ Object
28 29 30 |
# File 'lib/mtgapi/client.rb', line 28 def name_url(name) "/card/name/#{name}" end |
#set_url(set) ⇒ Object
32 33 34 |
# File 'lib/mtgapi/client.rb', line 32 def set_url(set) "/card/set/#{set}" end |
#sets ⇒ Object
15 16 17 |
# File 'lib/mtgapi/client.rb', line 15 def sets self.class.get("/list/sets").parsed_response end |
#token_append ⇒ Object
36 37 38 |
# File 'lib/mtgapi/client.rb', line 36 def token_append "?token=#{token}" end |