Class: Gloomhaven::Card
- Inherits:
-
Object
- Object
- Gloomhaven::Card
- Defined in:
- lib/gloomhaven/card.rb
Instance Attribute Summary collapse
-
#attack ⇒ Object
readonly
Returns the value of attribute attack.
-
#crit ⇒ Object
readonly
Returns the value of attribute crit.
-
#miss ⇒ Object
readonly
Returns the value of attribute miss.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#shuffle ⇒ Object
readonly
Returns the value of attribute shuffle.
Instance Method Summary collapse
- #bless? ⇒ Boolean
- #curse? ⇒ Boolean
-
#initialize(name) ⇒ Card
constructor
A new instance of Card.
- #rolling? ⇒ Boolean
Constructor Details
#initialize(name) ⇒ Card
Returns a new instance of Card.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/gloomhaven/card.rb', line 6 def initialize(name) raise ArgumentError.new('Name must be a string') unless name.is_a?(String) card_data = CARDS.detect { |card| card['name'].downcase == name.downcase } validate!(card_data) @name = card_data['name'] @attack = card_data['attack'] @crit = card_data['crit'] == true @miss = card_data['miss'] == true @rolling = card_data['rolling'] == true @shuffle = card_data['shuffle'] == true end |
Instance Attribute Details
#attack ⇒ Object (readonly)
Returns the value of attribute attack.
4 5 6 |
# File 'lib/gloomhaven/card.rb', line 4 def attack @attack end |
#crit ⇒ Object (readonly)
Returns the value of attribute crit.
4 5 6 |
# File 'lib/gloomhaven/card.rb', line 4 def crit @crit end |
#miss ⇒ Object (readonly)
Returns the value of attribute miss.
4 5 6 |
# File 'lib/gloomhaven/card.rb', line 4 def miss @miss end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/gloomhaven/card.rb', line 4 def name @name end |
#shuffle ⇒ Object (readonly)
Returns the value of attribute shuffle.
4 5 6 |
# File 'lib/gloomhaven/card.rb', line 4 def shuffle @shuffle end |
Instance Method Details
#bless? ⇒ Boolean
20 21 22 |
# File 'lib/gloomhaven/card.rb', line 20 def bless? name.downcase == 'bless' end |
#curse? ⇒ Boolean
24 25 26 |
# File 'lib/gloomhaven/card.rb', line 24 def curse? name.downcase == 'curse' end |
#rolling? ⇒ Boolean
28 29 30 |
# File 'lib/gloomhaven/card.rb', line 28 def rolling? @rolling end |