Class: LiarsDice::Bid

Inherits:
Object
  • Object
show all
Defined in:
lib/liars_dice/bid.rb

Direct Known Subclasses

BS

Instance Attribute Summary collapse

Instance Method Summary collapse

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_valueObject

Returns the value of attribute face_value.



3
4
5
# File 'lib/liars_dice/bid.rb', line 3

def face_value
  @face_value
end

#totalObject

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

Returns:

  • (Boolean)


10
11
12
# File 'lib/liars_dice/bid.rb', line 10

def bs_called?
  false
end

#to_sObject



14
15
16
# File 'lib/liars_dice/bid.rb', line 14

def to_s
  "#{total} #{face_value}#{"s" if total > 1}"
end

#valid?Boolean

Returns:

  • (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