Class: LiarsDice::Bid
- Inherits:
-
Object
- Object
- LiarsDice::Bid
- Defined in:
- lib/liars_dice/bid.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#face_value ⇒ Object
Returns the value of attribute face_value.
-
#total ⇒ Object
Returns the value of attribute total.
Instance Method Summary collapse
- #bs_called? ⇒ Boolean
-
#initialize(total, face_value) ⇒ Bid
constructor
A new instance of Bid.
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(total, face_value) ⇒ Bid
Returns a new instance of Bid.
5 6 7 8 |
# File 'lib/liars_dice/bid.rb', line 5 def initialize(total, face_value) self.total = total self.face_value = face_value end |
Instance Attribute Details
#face_value ⇒ Object
Returns the value of attribute face_value.
3 4 5 |
# File 'lib/liars_dice/bid.rb', line 3 def face_value @face_value end |
#total ⇒ Object
Returns the value of attribute total.
3 4 5 |
# File 'lib/liars_dice/bid.rb', line 3 def total @total end |
Instance Method Details
#bs_called? ⇒ Boolean
10 11 12 |
# File 'lib/liars_dice/bid.rb', line 10 def bs_called? false end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/liars_dice/bid.rb', line 14 def to_s "#{total} #{face_value}#{"s" if total > 1}" end |
#valid? ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/liars_dice/bid.rb', line 18 def valid? if face_value < 1 || face_value > 6 # Can't bid a face_value that doesn't exist return false elsif total < 1 # Have to bid a positive total return false end true end |