Class: Card
- Inherits:
-
Object
- Object
- Card
- Defined in:
- lib/magic_tcg_finder/card.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#card_type ⇒ Object
Returns the value of attribute card_type.
-
#color ⇒ Object
Returns the value of attribute color.
-
#combat_stats ⇒ Object
Returns the value of attribute combat_stats.
-
#cost ⇒ Object
Returns the value of attribute cost.
-
#flavor_text ⇒ Object
Returns the value of attribute flavor_text.
-
#name ⇒ Object
Returns the value of attribute name.
-
#price ⇒ Object
Returns the value of attribute price.
-
#purchase_url ⇒ Object
Returns the value of attribute purchase_url.
-
#rarity ⇒ Object
Returns the value of attribute rarity.
-
#rules_text ⇒ Object
Returns the value of attribute rules_text.
-
#sets ⇒ Object
Returns the value of attribute sets.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #add_card_attributes(attribute_hash) ⇒ Object
-
#initialize(attributes) ⇒ Card
constructor
A new instance of Card.
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_type ⇒ Object
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 |
#color ⇒ Object
Returns the value of attribute color.
3 4 5 |
# File 'lib/magic_tcg_finder/card.rb', line 3 def color @color end |
#combat_stats ⇒ Object
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 |
#cost ⇒ Object
Returns the value of attribute cost.
3 4 5 |
# File 'lib/magic_tcg_finder/card.rb', line 3 def cost @cost end |
#flavor_text ⇒ Object
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 |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/magic_tcg_finder/card.rb', line 3 def name @name end |
#price ⇒ Object
Returns the value of attribute price.
3 4 5 |
# File 'lib/magic_tcg_finder/card.rb', line 3 def price @price end |
#purchase_url ⇒ Object
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 |
#rarity ⇒ Object
Returns the value of attribute rarity.
3 4 5 |
# File 'lib/magic_tcg_finder/card.rb', line 3 def rarity @rarity end |
#rules_text ⇒ Object
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 |
#sets ⇒ Object
Returns the value of attribute sets.
3 4 5 |
# File 'lib/magic_tcg_finder/card.rb', line 3 def sets @sets end |
#url ⇒ Object
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
.all ⇒ Object
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_all ⇒ Object
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 |