Sha256: 0ed04233668bef808db74cda94285db63b5ef72f4435e1f984acd781b5136635

Contents?: true

Size: 690 Bytes

Versions: 2

Compression:

Stored size: 690 Bytes

Contents

# A collection of mutually exclusive events.
#--
# The events are not currently enforced as being
# mutually exclusive so are really just plain
# old events right now.
class MutuallyExclusiveCollection
  # create a new collection with the given events
  def initialize(events)
    @events = events.sort
  end

  # the least likely of the events to occur
  def underdog
    @events.first
  end

  # the most likely of the events to occur
  def favorite
    @events.last
  end  

  # the events in ascending order of probability
  def in_ascending_probability
    @events
  end

  # the events in descending order of probability
  def in_descending_probability
    @events.reverse
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rodders-0.1.1 lib/MutuallyExclusiveCollection.rb
rodders-0.1.0 lib/MutuallyExclusiveCollection.rb