Class: Card
- Inherits:
-
Object
- Object
- Card
- Defined in:
- lib/model/card.rb
Constant Summary collapse
- @@card_types =
[]
Class Method Summary collapse
Instance Method Summary collapse
- #get_image_path ⇒ Object
-
#initialize(card_type, theme) ⇒ Card
constructor
A new instance of Card.
- #is_major_arcana ⇒ Object
- #is_minor_arcana ⇒ Object
Constructor Details
#initialize(card_type, theme) ⇒ Card
Returns a new instance of Card.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/model/card.rb', line 7 def initialize(card_type, theme) @card_type = card_type @theme = theme if !Card.get_card_types.include? @card_type @card_type = nil @theme = nil raise ArgumentError.new("Invalid card_type: " + card_type) end end |
Class Method Details
.get_card_types ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/model/card.rb', line 19 def self.get_card_types if !@@card_types || @@card_types.size == 0 file = File.read("lib/model/card_types.json"); @@card_types = JSON.parse(file)["card_types"] end @@card_types end |
Instance Method Details
#get_image_path ⇒ Object
27 28 29 |
# File 'lib/model/card.rb', line 27 def get_image_path "../../tarot-cards/#{@theme}/#{@card_type}.jpg" end |
#is_major_arcana ⇒ Object
30 31 32 |
# File 'lib/model/card.rb', line 30 def is_major_arcana false end |
#is_minor_arcana ⇒ Object
34 35 36 |
# File 'lib/model/card.rb', line 34 def is_minor_arcana false end |