module Oddsmaker::Odd

Odds represent a single value that can be bet on. This can be represented and converted between the various forms it can take:

Public Class Methods

american(value, id = nil) click to toggle source

Create American odds with the given value.

@param value [String, Integer] Odds value @param id [String] Identifier for this odd. Useful when multiple odds are used in a market @return [American]

# File lib/oddsmaker/odd.rb, line 26
def self.american(value, id = nil)
  American.new(value, id)
end
decimal(value, id = nil) click to toggle source

Create decimal odds with the given value.

@param value [Float, Integer] Odds value @param id [String] Identifier for this odd. Useful when multiple odds are used in a market @return [Decimal]

# File lib/oddsmaker/odd.rb, line 35
def self.decimal(value, id = nil)
  Decimal.new(value, id)
end
fractional(value, id = nil) click to toggle source

Create fractional odds with the given value.

@param value [String, Integer] Odds value @param id [String] Identifier for this odd. Useful when multiple odds are used in a market @return [Fractional]

# File lib/oddsmaker/odd.rb, line 44
def self.fractional(value, id = nil)
  Fractional.new(value, id)
end
implied(value, id = nil) click to toggle source

Create an implied probability with the given value.

@param value [Float, Integer] Probability value @param id [String] Identifier for this odd. Useful when multiple odds are used in a market @return [ImpliedProbability]

# File lib/oddsmaker/odd.rb, line 17
def self.implied(value, id = nil)
  ImpliedProbability.new(value, id)
end
new(params = {}) click to toggle source

Shortcut to creating a new odd based off hash params (i.e. request params). Requires one of `%w[american decimal fraction implied]` keys. Also accepts param `'name'`.

@return [Odd]

# File lib/oddsmaker/odd.rb, line 53
def self.new(params = {})
  if (type = %w[american decimal fraction implied].detect { |type| params.key?(type) })
    send(type, params[type], params['name'])
  end
end