Class: Equity

Inherits:
Object
  • Object
show all
Defined in:
lib/rora/model/equity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_tiedObject

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_wonObject

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_handObject

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_handsObject

Returns the value of attribute total_hands.



3
4
5
# File 'lib/rora/model/equity.rb', line 3

def total_hands
  @total_hands
end

#valueObject

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_sObject



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