class ROdds::ConvertOdd

Constants

DEFAULT_FORMAT

Attributes

from[R]
raw_odd[R]
to[R]

Public Class Methods

call(params) click to toggle source
# File lib/r_odds/convert_odd.rb, line 5
def self.call(params)
  new(params).call
end
new(params) click to toggle source
# File lib/r_odds/convert_odd.rb, line 9
def initialize(params)
  @raw_odd = params[:raw_odd]
  @from    = params[:from] || infered_format
  @to      = params[:to]
end

Public Instance Methods

call() click to toggle source
# File lib/r_odds/convert_odd.rb, line 15
def call
  standardized_odd = ROdds::Odd::Standardizer.call(odd: raw_odd, format: from)

  implied_probability = default_conversion_class.call(standardized_odd)

  converted_odd = final_conversion_class.call(implied_probability)

  converted_odd.to_s
end

Private Instance Methods

default_conversion_class() click to toggle source
# File lib/r_odds/convert_odd.rb, line 32
def default_conversion_class
  ROdds::OddConverter::ClassFactory.call(from: from, to: DEFAULT_FORMAT)
end
final_conversion_class() click to toggle source
# File lib/r_odds/convert_odd.rb, line 36
def final_conversion_class
  ROdds::OddConverter::ClassFactory.call(from: DEFAULT_FORMAT, to: to)
end
infered_format() click to toggle source
# File lib/r_odds/convert_odd.rb, line 28
def infered_format
  ROdds::InferOddFormat.of(odd: raw_odd)
end