class Oddsmaker::Odd::Base
@abstract Base
class to implement common functionality to various types of odds.
Attributes
Public Instance Methods
Compare two odds against each other.
@param other [Odd] @return [-1,0,1]
# File lib/oddsmaker/odd/base.rb, line 58 def <=>(other) implied_probability <=> other.implied_probability end
Check two odds for equality.
@param other [Odd] @return [Boolean]
# File lib/oddsmaker/odd/base.rb, line 50 def ==(other) implied_probability == other.implied_probability end
Calculate implied probability.
@return [ImpliedProbability]
# File lib/oddsmaker/odd/base.rb, line 34 def implied_probability @implied_probability ||= ImpliedProbability.new(calculate_probability, id) end
Multiplier is commonly used for parlay and other calculations. It's just decimal odds, but we define it to match common terminology.
@return [Float]
# File lib/oddsmaker/odd/base.rb, line 42 def multiplier self.decimal.value end
Calculates a new odd, with the given overround percentage.
@param v [Integer] Overround percentage (as whole number) @return [Odd] Returns the same class as the original object
# File lib/oddsmaker/odd/base.rb, line 27 def overround!(v) implied_probability.overround!(v).send(type) end
Calculate profit for an amount wagered. Convenient if a `Wager` object is unnecessary.
@param amount [Integer, Float] Amount wagered. Can be integer or float. @return [Float, Integer, Rational]
# File lib/oddsmaker/odd/base.rb, line 75 def profit(amount) calculate_profit(amount) end
Represent odd as a hash. This will include all forms of the odd. @return [Hash]
# File lib/oddsmaker/odd/base.rb, line 82 def to_h { name: self.name, american: self.american.value, decimal: self.decimal.value, fractional: self.fractional.value, implied: self.implied_probability.value, } end
JSON representation of the odd. @return [String]
# File lib/oddsmaker/odd/base.rb, line 94 def to_json to_h.to_json end
Display odds as a string
@return [String]
# File lib/oddsmaker/odd/base.rb, line 12 def to_s @value.to_s end
Make a wager with this odd.
@param amount [Integer, Float] Amount wagered. Can be integer or float. @return [Wager]
# File lib/oddsmaker/odd/base.rb, line 66 def wager(amount) Wager.new(amount, self) end
Calculates a new odd, removing the vig.
@return [Odd] Returns the same class as the original object
# File lib/oddsmaker/odd/base.rb, line 19 def without_vig(total_probability) @without_vig = implied_probability.without_vig(total_probability).send(type) end