Class: HearthstoneCardApi::Public
- Inherits:
-
Object
- Object
- HearthstoneCardApi::Public
- Defined in:
- lib/hearthstone_card_api.rb
Instance Attribute Summary collapse
-
#call ⇒ Object
Returns the value of attribute call.
Instance Method Summary collapse
-
#get_card_by_id(args = {}) ⇒ Object
expects :id.
-
#get_card_by_name(args = {}) ⇒ Object
expects :name.
- #get_cards(args = {}) ⇒ Object
-
#get_cards_by(args = {}) ⇒ Object
expects :value.
- #get_info ⇒ Object
-
#initialize(args = {}) ⇒ Public
constructor
A new instance of Public.
-
#search_cards(args = {}) ⇒ Object
expects :name.
Constructor Details
#initialize(args = {}) ⇒ Public
Returns a new instance of Public.
16 17 18 |
# File 'lib/hearthstone_card_api.rb', line 16 def initialize(args={}) @call = HearthstoneCardApi::Caller.new end |
Instance Attribute Details
#call ⇒ Object
Returns the value of attribute call.
14 15 16 |
# File 'lib/hearthstone_card_api.rb', line 14 def call @call end |
Instance Method Details
#get_card_by_id(args = {}) ⇒ Object
expects :id
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/hearthstone_card_api.rb', line 46 def get_card_by_id(args={}) #expects {:id} url = "cards/#{args[:id]}" args[:url] = url data = call.return_cards(args) if data.is_a? Hash or data.is_a? String #if 404 error, hash, or string return data else return data[0] #else return single obj end end |
#get_card_by_name(args = {}) ⇒ Object
expects :name
57 58 59 60 61 62 |
# File 'lib/hearthstone_card_api.rb', line 57 def get_card_by_name(args={}) #expects {:name} name = args[:name] url = "cards/#{name}" args[:url] = url call.return_cards(args) end |
#get_cards(args = {}) ⇒ Object
25 26 27 28 29 |
# File 'lib/hearthstone_card_api.rb', line 25 def get_cards(args={}) url = "cards" args[:url] = url call.return_cards(args) end |
#get_cards_by(args = {}) ⇒ Object
expects :value
38 39 40 41 42 43 44 |
# File 'lib/hearthstone_card_api.rb', line 38 def get_cards_by(args={}) #expects {:trait, :value} trait = args[:trait] value = args[:value] url= "cards/#{trait}/#{value}" args[:url] = url call.return_cards(args) end |
#get_info ⇒ Object
20 21 22 23 |
# File 'lib/hearthstone_card_api.rb', line 20 def get_info url = "info" call.return_info(url) end |
#search_cards(args = {}) ⇒ Object
expects :name
31 32 33 34 35 36 |
# File 'lib/hearthstone_card_api.rb', line 31 def search_cards(args={}) #expects {:name} name = args[:name] url= "cards/search/#{name}" args[:url] = url call.return_cards(args) end |