Module: Oddsmaker::Odd
- Defined in:
- lib/oddsmaker/odd.rb,
lib/oddsmaker/odd/base.rb,
lib/oddsmaker/odd/decimal.rb,
lib/oddsmaker/odd/american.rb,
lib/oddsmaker/odd/fractional.rb,
lib/oddsmaker/odd/implied_probability.rb
Overview
Odds represent a single value that can be bet on. This can be represented and converted between the various forms it can take:
-
Implied probability
-
Decimal odds
-
Fractional odds
-
American odds
Defined Under Namespace
Classes: American, Base, Decimal, Fractional, ImpliedProbability
Class Method Summary collapse
-
.american(value, id = nil) ⇒ American
Create American odds with the given value.
-
.decimal(value, id = nil) ⇒ Decimal
Create decimal odds with the given value.
-
.fractional(value, id = nil) ⇒ Fractional
Create fractional odds with the given value.
-
.implied(value, id = nil) ⇒ ImpliedProbability
Create an implied probability with the given value.
-
.new(params = {}) ⇒ Odd
Shortcut to creating a new odd based off hash params (i.e. request params).
Class Method Details
.american(value, id = nil) ⇒ American
Create American odds with the given value.
26 27 28 |
# File 'lib/oddsmaker/odd.rb', line 26 def self.american(value, id = nil) American.new(value, id) end |
.decimal(value, id = nil) ⇒ Decimal
Create decimal odds with the given value.
35 36 37 |
# File 'lib/oddsmaker/odd.rb', line 35 def self.decimal(value, id = nil) Decimal.new(value, id) end |
.fractional(value, id = nil) ⇒ Fractional
Create fractional odds with the given value.
44 45 46 |
# File 'lib/oddsmaker/odd.rb', line 44 def self.fractional(value, id = nil) Fractional.new(value, id) end |
.implied(value, id = nil) ⇒ ImpliedProbability
Create an implied probability with the given value.
17 18 19 |
# File 'lib/oddsmaker/odd.rb', line 17 def self.implied(value, id = nil) ImpliedProbability.new(value, id) end |
.new(params = {}) ⇒ Odd
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’‘.
53 54 55 56 57 |
# 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 |