lib/bridge/score.rb in bridge-0.0.20 vs lib/bridge/score.rb in bridge-0.0.21
- old
+ new
@@ -1,8 +1,17 @@
module Bridge
class Score
attr_reader :tricks, :contract, :vulnerable
+ # Checks contract with result, i.e. "1NTX-1", "2S=", "6SXX+1"
+ # on Ruby >= 1.9 there are named groups :contract and :result
+ # on Ruby < 1.9 there are: contract on $1 and result on $5
+ if RUBY_VERSION >= "1.9"
+ REGEXP = Regexp.new %q{\A(?<contract>([1-7])([CDHS]|NT)(X{1,2})?)(?<result>=|\+[1-6]|-([1-9]|1[0-3]))\Z}
+ else
+ REGEXP = Regexp.new %q{\A(([1-7])([CDHS]|NT)(X{1,2})?)(=|\+[1-6]|-([1-9]|1[0-3]))\Z}
+ end
+
# Creates new score object
#
# ==== Example
# Bridge::Score.new(:contract => "7SXX", :vulnerable => true, :tricks => "=")
def initialize(options = {})
\ No newline at end of file