class ROdds::InferOddFormat
Attributes
odd[R]
Public Class Methods
new(params)
click to toggle source
# File lib/r_odds/infer_odd_format.rb, line 8 def initialize(params) @odd = params[:odd] end
of(params)
click to toggle source
# File lib/r_odds/infer_odd_format.rb, line 4 def self.of(params) new(params).call end
Public Instance Methods
call()
click to toggle source
# File lib/r_odds/infer_odd_format.rb, line 12 def call case odd when /^(?:[1-9]\d*)+(\/|:)(?:[1-9]\d*)+$/ :fractional when /^[+-]?[1-9]\d{2,}\.?\d*$/ :american when /\d*.?\d++%/ :implied_probability when /^[1-9]\d*(\.\d+)$/ :decimal else raise ArgumentError, "Odd given in unknown format. See docs for acceptable formats" end end