class Oddsmaker::Odd::Decimal

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.

Public Class Methods

new(value, id = nil) click to toggle source
# File lib/oddsmaker/odd/decimal.rb, line 7
def initialize(value, id = nil)
  @id    = id || value
  @value = value.to_f
end

Public Instance Methods

american() click to toggle source

Convert to American odds, returning a new object.

@return [American]

# File lib/oddsmaker/odd/decimal.rb, line 22
def american
  @american ||= implied_probability.american
end
decimal() click to toggle source

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

@return [self]

# File lib/oddsmaker/odd/decimal.rb, line 15
def decimal
  self
end
fractional() click to toggle source

Convert to fractional odds, returning a new object.

@return [Fractional]

# File lib/oddsmaker/odd/decimal.rb, line 29
def fractional
  @fractional ||= implied_probability.fractional
end

Private Instance Methods

calculate_probability() click to toggle source

Calculate implied probability of an odd.

@return [Float]

# File lib/oddsmaker/odd/decimal.rb, line 43
def calculate_probability
  1.0 / @value
end
calculate_profit(amount) click to toggle source

Calculate profit for a wager.

@return [Float, Integer]

# File lib/oddsmaker/odd/decimal.rb, line 50
def calculate_profit(amount)
  (@value - 1) * amount
end
type() click to toggle source

Allows for implied probability to create a vigged/unvigged odd and convert it back to source format.

# File lib/oddsmaker/odd/decimal.rb, line 36
def type
  :decimal
end