class Bridge::Call
Abstract class, inherited by Bid
, Pass
, Double
and Redouble
.
Public Class Methods
all()
click to toggle source
# File lib/bridge/call.rb, line 47 def self.all calls = Strain.all.map { |s| Level.all.map { |l| Bid.new(l,s) } }.flatten calls << Double.new calls << Redouble.new calls << Pass.new calls end
from_string(string)
click to toggle source
# File lib/bridge/call.rb, line 26 def self.from_string string string ||= '' call = nil case string.downcase when 'p','pass' call = Pass.new when 'd', 'double' call = Double.new when 'r', 'redouble' call = Redouble.new when /^bi?d? [a-z]{3,5} [a-z\s\_]{4,8}$/i bid = string.split bid.shift # get rid of 'bid' level = bid.shift strain = bid.join('_') call = Bid.new(level,strain) end raise CallError.new, "'#{string}' is not a call" if call.nil? call end
Public Instance Methods
to_s()
click to toggle source
# File lib/bridge/call.rb, line 55 def to_s self.class.to_s.downcase.gsub('bridge::','') end