acpc_poker_types 3.2.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/acpc_poker_types/poker_action.rb +32 -7
- data/lib/acpc_poker_types/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 621b7409ffa2bb10cfd149ea4095d18e01e2fb78
|
4
|
+
data.tar.gz: 7a6b6c71dafcea5276d4a0cbccf01e24b9621a03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b3f6989f5dbb77fac80ac711e0783928acb55345add460f42bb6d6860cf5c9bbaf233f6b36e69ec5c3a1a4050928f9b64bfa8a68f134683b272072355e4a858
|
7
|
+
data.tar.gz: 63face898038f4ff0a877aab6d0512af11c0a0f639db5d3e4455cb53e8a16d0d1d2ba1b686abb310c09162561f436d29150afe7f3178bedd44f2abb1e738e665
|
@@ -5,6 +5,31 @@ require 'acpc_poker_types/chip_stack'
|
|
5
5
|
require 'contextual_exceptions'
|
6
6
|
using ContextualExceptions::ClassRefinement
|
7
7
|
|
8
|
+
module BlankRefinement
|
9
|
+
refine Object do
|
10
|
+
def blank?
|
11
|
+
respond_to?(:empty?) ? empty? : !self
|
12
|
+
end
|
13
|
+
end
|
14
|
+
refine NilClass do
|
15
|
+
def blank?
|
16
|
+
true
|
17
|
+
end
|
18
|
+
def strip
|
19
|
+
self
|
20
|
+
end
|
21
|
+
end
|
22
|
+
refine Array do
|
23
|
+
alias_method :blank?, :empty?
|
24
|
+
end
|
25
|
+
refine String do
|
26
|
+
def blank?
|
27
|
+
self !~ /\S/
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
using BlankRefinement
|
32
|
+
|
8
33
|
module AcpcPokerTypes
|
9
34
|
class PokerAction
|
10
35
|
exceptions :illegal_action, :illegal_modification
|
@@ -43,7 +68,7 @@ module AcpcPokerTypes
|
|
43
68
|
# +:pot_gained_chips+, and +:cost+.
|
44
69
|
# @raise IllegalAction
|
45
70
|
def initialize(action, modifier: nil, cost: AcpcPokerTypes::ChipStack.new(0))
|
46
|
-
validate_action!(action, modifier)
|
71
|
+
validate_action!(action, modifier.strip)
|
47
72
|
@cost = cost
|
48
73
|
end
|
49
74
|
|
@@ -71,7 +96,7 @@ module AcpcPokerTypes
|
|
71
96
|
|
72
97
|
# @return [Boolean] +true+ if this action has a modifier, +false+ otherwise.
|
73
98
|
def has_modifier?
|
74
|
-
!@modifier.
|
99
|
+
!@modifier.blank?
|
75
100
|
end
|
76
101
|
|
77
102
|
private
|
@@ -85,18 +110,18 @@ module AcpcPokerTypes
|
|
85
110
|
raise IllegalAction if action_string.empty?
|
86
111
|
@action = action_string[0]
|
87
112
|
raise IllegalAction unless ACTIONS.include?(@action)
|
88
|
-
@modifier = action_string[1..-1] unless action_string.length < 2
|
113
|
+
@modifier = action_string[1..-1].strip unless action_string.length < 2
|
89
114
|
|
90
|
-
if given_modifier &&
|
115
|
+
if !given_modifier.blank? && !@modifier.blank?
|
91
116
|
raise(
|
92
117
|
IllegalModification,
|
93
118
|
"in-place modifier: #{@modifier}, explicit modifier: #{given_modifier}"
|
94
119
|
)
|
95
120
|
end
|
96
121
|
|
97
|
-
@modifier = if
|
122
|
+
@modifier = if !@modifier.blank?
|
98
123
|
@modifier
|
99
|
-
elsif given_modifier
|
124
|
+
elsif !given_modifier.blank?
|
100
125
|
given_modifier
|
101
126
|
end
|
102
127
|
|
@@ -106,7 +131,7 @@ module AcpcPokerTypes
|
|
106
131
|
end
|
107
132
|
|
108
133
|
def validate_modifier
|
109
|
-
raise(IllegalModification, "Illegal modifier: #{@modifier}") unless @modifier.
|
134
|
+
raise(IllegalModification, "Illegal modifier: #{@modifier}") unless @modifier.blank? || AcpcPokerTypes::PokerAction::MODIFIABLE_ACTIONS.include?(@action)
|
110
135
|
end
|
111
136
|
end
|
112
137
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acpc_poker_types
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Morrill
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: process_runner
|