Sha256: 89f3497dddfa4fa8db4cc343f9a9ac4f6724743fde10ca9f85924161b3c44898

Contents?: true

Size: 833 Bytes

Versions: 3

Compression:

Stored size: 833 Bytes

Contents

# A collection of mutually exclusive events.
class MutuallyExclusiveCollection
  # create a new collection with the given events
  # @param [Array<FixedOdds>] events the events
  def initialize(events)
    @events = events.sort
  end

  # the least likely of the events to occur
  # @return [FixedOdds] the least likely event
  def underdog
    @events.first
  end

  # the most likely of the events to occur
  # @return [FixedOdds] the most likely event
  def favorite
    @events.last
  end  

  # the events in ascending order of probability
  # @return [Array<FixedOdds>] events in ascending probability
  def in_ascending_probability
    @events
  end

  # the events in descending order of probability
  # @return [Array<FixedOdds>] events in descending probability
  def in_descending_probability
    @events.reverse
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rodders-0.3.0 lib/MutuallyExclusiveCollection.rb
rodders-0.2.0 lib/MutuallyExclusiveCollection.rb
rodders-0.1.2 lib/MutuallyExclusiveCollection.rb