Class: Bridge::Call
- Inherits:
-
Object
show all
- Defined in:
- lib/bridge/call.rb
Overview
Abstract class, inherited by Bid, Pass, Double and Redouble.
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.all ⇒ Object
47
48
49
50
51
52
53
|
# 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) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# 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 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
|
Instance Method Details
#to_s ⇒ Object
55
56
57
|
# File 'lib/bridge/call.rb', line 55
def to_s
self.class.to_s.downcase.gsub('bridge::','')
end
|