class Bridge::Bid

A Bid represents a statement of a level and a strain. @param level: the level of the bid. @type level: L{Level} @param strain: the strain (denomination) of the bid. @type strain: L{Strain}

Attributes

level[RW]
strain[RW]

Public Class Methods

new(level, strain) click to toggle source
# File lib/bridge/call.rb, line 68
def initialize(level, strain)
  self.level  = level.is_a?(Integer)  ? level : Level.send(level.to_sym)
  self.strain = strain.is_a?(Integer) ? strain : Strain.send(strain.to_sym)
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/bridge/call.rb, line 74
def <=>(other)
  if other.is_a?(Bid) # Compare two bids.
    s_size = Strain.values.size
    # puts "#{self.level*s_size + self.strain} <=> #{other.level*s_size + other.strain}"
    (self.level*s_size + self.strain) <=> (other.level*s_size + other.strain)
  else # Comparing non-bid calls returns true.
    1
  end
end
to_s() click to toggle source
# File lib/bridge/call.rb, line 84
def to_s
  "#{Level.name(level)} #{Strain.name(strain)}"
end