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.
68 69 70 71 |
# 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 |
Instance Attribute Details
#level ⇒ Object
Returns the value of attribute level.
66 67 68 |
# File 'lib/bridge/call.rb', line 66 def level @level end |
#strain ⇒ Object
Returns the value of attribute strain.
66 67 68 |
# File 'lib/bridge/call.rb', line 66 def strain @strain end |
Instance Method Details
#<=>(other) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# 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 ⇒ Object
84 85 86 |
# File 'lib/bridge/call.rb', line 84 def to_s "#{Level.name(level)} #{Strain.name(strain)}" end |