Class: Bridge::Bid
Overview
A Bid represents a statement of a level and a strain.
Instance Attribute Summary collapse
-
#level ⇒ Object
Returns the value of attribute level.
-
#strain ⇒ Object
Returns the value of attribute strain.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(level, strain) ⇒ Bid
constructor
A new instance of Bid.
- #to_s ⇒ Object
Methods inherited from Call
Constructor Details
#initialize(level, strain) ⇒ Bid
Returns a new instance of Bid.
69 70 71 72 |
# File 'lib/bridge/call.rb', line 69 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 |
Instance Attribute Details
#level ⇒ Object
Returns the value of attribute level.
67 68 69 |
# File 'lib/bridge/call.rb', line 67 def level @level end |
#strain ⇒ Object
Returns the value of attribute strain.
67 68 69 |
# File 'lib/bridge/call.rb', line 67 def strain @strain end |
Instance Method Details
#<=>(other) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/bridge/call.rb', line 75 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 ⇒ Object
85 86 87 |
# File 'lib/bridge/call.rb', line 85 def to_s "#{Level.name(level)} #{Strain.name(strain)}" end |