Class: Equity
- Inherits:
-
Object
- Object
- Equity
- Defined in:
- lib/rora/model/equity.rb
Instance Attribute Summary collapse
-
#hands_tied ⇒ Object
Returns the value of attribute hands_tied.
-
#hands_won ⇒ Object
Returns the value of attribute hands_won.
-
#starting_hand ⇒ Object
Returns the value of attribute starting_hand.
-
#total_hands ⇒ Object
Returns the value of attribute total_hands.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(total_hands_played, total_hands_won, result) ⇒ Equity
constructor
A new instance of Equity.
- #to_s ⇒ Object
Constructor Details
#initialize(total_hands_played, total_hands_won, result) ⇒ Equity
Returns a new instance of Equity.
5 6 7 8 9 10 11 12 |
# File 'lib/rora/model/equity.rb', line 5 def initialize(total_hands_played, total_hands_won, result) @starting_hand = result[0] @total_hands = total_hands_played @hands_won = result[1] @hands_tied = total_hands_played - total_hands_won total_equity = @hands_won + @hands_tied @value = (total_equity == 0 ? 0.00 : total_equity.quo(@total_hands) * 100.00) end |
Instance Attribute Details
#hands_tied ⇒ Object
Returns the value of attribute hands_tied.
3 4 5 |
# File 'lib/rora/model/equity.rb', line 3 def hands_tied @hands_tied end |
#hands_won ⇒ Object
Returns the value of attribute hands_won.
3 4 5 |
# File 'lib/rora/model/equity.rb', line 3 def hands_won @hands_won end |
#starting_hand ⇒ Object
Returns the value of attribute starting_hand.
3 4 5 |
# File 'lib/rora/model/equity.rb', line 3 def starting_hand @starting_hand end |
#total_hands ⇒ Object
Returns the value of attribute total_hands.
3 4 5 |
# File 'lib/rora/model/equity.rb', line 3 def total_hands @total_hands end |
#value ⇒ Object
Returns the value of attribute value.
3 4 5 |
# File 'lib/rora/model/equity.rb', line 3 def value @value end |
Instance Method Details
#to_s ⇒ Object
14 15 16 |
# File 'lib/rora/model/equity.rb', line 14 def to_s "starting hand: #{@starting_hand.key} => hands: #{@total_hands}, won: #{@hands_won}, tied: #{@hands_tied}, equity: #{sprintf("%05.3f", @value)}%" end |