Class: Card

Inherits:
Object
  • Object
show all
Defined in:
lib/magic_tcg_finder/card.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Card

Returns a new instance of Card.



7
8
9
10
# File 'lib/magic_tcg_finder/card.rb', line 7

def initialize(attributes)
  attributes.each {|attribute, value| self.send(("#{attribute}="), value)}
  @@all << self
end

Instance Attribute Details

#card_typeObject

Returns the value of attribute card_type.



3
4
5
# File 'lib/magic_tcg_finder/card.rb', line 3

def card_type
  @card_type
end

#colorObject

Returns the value of attribute color.



3
4
5
# File 'lib/magic_tcg_finder/card.rb', line 3

def color
  @color
end

#combat_statsObject

Returns the value of attribute combat_stats.



3
4
5
# File 'lib/magic_tcg_finder/card.rb', line 3

def combat_stats
  @combat_stats
end

#costObject

Returns the value of attribute cost.



3
4
5
# File 'lib/magic_tcg_finder/card.rb', line 3

def cost
  @cost
end

#flavor_textObject

Returns the value of attribute flavor_text.



3
4
5
# File 'lib/magic_tcg_finder/card.rb', line 3

def flavor_text
  @flavor_text
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/magic_tcg_finder/card.rb', line 3

def name
  @name
end

#priceObject

Returns the value of attribute price.



3
4
5
# File 'lib/magic_tcg_finder/card.rb', line 3

def price
  @price
end

#purchase_urlObject

Returns the value of attribute purchase_url.



3
4
5
# File 'lib/magic_tcg_finder/card.rb', line 3

def purchase_url
  @purchase_url
end

#rarityObject

Returns the value of attribute rarity.



3
4
5
# File 'lib/magic_tcg_finder/card.rb', line 3

def rarity
  @rarity
end

#rules_textObject

Returns the value of attribute rules_text.



3
4
5
# File 'lib/magic_tcg_finder/card.rb', line 3

def rules_text
  @rules_text
end

#setsObject

Returns the value of attribute sets.



3
4
5
# File 'lib/magic_tcg_finder/card.rb', line 3

def sets
  @sets
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/magic_tcg_finder/card.rb', line 3

def url
  @url
end

Class Method Details

.allObject



12
13
14
# File 'lib/magic_tcg_finder/card.rb', line 12

def self.all
  @@all
end

.create_from_collection(card_arr) ⇒ Object



20
21
22
23
24
# File 'lib/magic_tcg_finder/card.rb', line 20

def self.create_from_collection(card_arr)
  card_arr.each do |card|
    new_card = Card.new(card)
  end
end

.destroy_allObject



16
17
18
# File 'lib/magic_tcg_finder/card.rb', line 16

def self.destroy_all
  self.all.clear
end

Instance Method Details

#add_card_attributes(attribute_hash) ⇒ Object



26
27
28
# File 'lib/magic_tcg_finder/card.rb', line 26

def add_card_attributes(attribute_hash)
  attribute_hash.each {|attribute, value| self.send(("#{attribute}="), value)}
end