Sha256: 3a60dd4c9c62c466c7987cde3a2ffd00de9d59cabb08b055ad80798db8b08767
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
require_relative 'representers/set_representer' require_relative 'card' require_relative 'rest_client' module MTG class Set include Roar::JSON include SetRepresenter include RestClient attr_accessor :code, :name, :type, :border, :mkm_id, :mkm_name, :release_date, :gatherer_code, :magic_cards_info_code, :booster, :old_code, :block, :online_only # Get the resource string # # @return [string] The API resource string def self.Resource "sets" end # Find a single set by the set code # # @param code [String] the Set code # @return [Set] a Set object def self.find(code) QueryBuilder.new(Set).find(code) end # Get all sets from a query # # @return [Array<Set>] Array of Set objects def self.all QueryBuilder.new(Set).all end # Adds a parameter to the hash of query parameters # # @param args [Hash] the query parameter # @return [QueryBuilder] the QueryBuilder def self.where(args) QueryBuilder.new(Set).where(args) end # Generate a booster pack for a specific set # @param code [String] the Set code # @return [Array<Card>] Array of Card objects def self.generate_booster(code) cards = [] response = RestClient.get("sets/#{code}/booster") data = response.body['cards'] data.each do |card| cards << Card.new.from_json(card.to_json) end cards end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mtg_sdk-3.2.1 | lib/mtg_sdk/set.rb |