Class: Oddsmaker::Odd::Decimal

Inherits:
Base
  • Object
show all
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

#id, #value

Instance Method Summary collapse

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

#americanAmerican

Convert to American odds, returning a new object.

Returns:



22
23
24
# File 'lib/oddsmaker/odd/decimal.rb', line 22

def american
  @american ||= implied_probability.american
end

#decimalself

Returns self. This creates a consistent API for all odds.

Returns:

  • (self)


15
16
17
# File 'lib/oddsmaker/odd/decimal.rb', line 15

def decimal
  self
end

#fractionalFractional

Convert to fractional odds, returning a new object.

Returns:



29
30
31
# File 'lib/oddsmaker/odd/decimal.rb', line 29

def fractional
  @fractional ||= implied_probability.fractional
end