Class: Oddsmaker::Odd::Decimal
- Defined in:
- lib/oddsmaker/odd/decimal.rb
Overview
Decimal odds express the amount that would be returned from a $1 wager, including the original wager amount. Decimal odds will always be greater than 1.0.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#american ⇒ American
Convert to American odds, returning a new object.
-
#decimal ⇒ self
Returns self.
-
#fractional ⇒ Fractional
Convert to fractional odds, returning a new object.
-
#initialize(value, id = nil) ⇒ Decimal
constructor
A new instance of Decimal.
Methods inherited from Base
#<=>, #==, #implied_probability, #multiplier, #overround!, #profit, #to_h, #to_json, #to_s, #wager, #without_vig
Constructor Details
#initialize(value, id = nil) ⇒ Decimal
Returns a new instance of Decimal.
7 8 9 10 |
# File 'lib/oddsmaker/odd/decimal.rb', line 7 def initialize(value, id = nil) @id = id || value @value = value.to_f end |
Instance Method Details
#american ⇒ American
Convert to American odds, returning a new object.
22 23 24 |
# File 'lib/oddsmaker/odd/decimal.rb', line 22 def american @american ||= implied_probability.american end |
#decimal ⇒ self
Returns self. This creates a consistent API for all odds.
15 16 17 |
# File 'lib/oddsmaker/odd/decimal.rb', line 15 def decimal self end |
#fractional ⇒ Fractional
Convert to fractional odds, returning a new object.
29 30 31 |
# File 'lib/oddsmaker/odd/decimal.rb', line 29 def fractional @fractional ||= implied_probability.fractional end |