Sha256: 2c8d2ce42b199369aaf1f1f5a5499722961b44d4ac2ccf8fd9c56b9ee215f5ff

Contents?: true

Size: 840 Bytes

Versions: 2

Compression:

Stored size: 840 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 least_likely
    @events.first
  end

  # the most likely of the events to occur
  # @return [FixedOdds] the most likely event
  def most_likely
    @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

2 entries across 2 versions & 1 rubygems

Version Path
rodders-2.1.0 lib/mutually_exclusive_collection.rb
rodders-1.0.0 lib/MutuallyExclusiveCollection.rb