Class: StackWars::TextClient
- Inherits:
-
Object
- Object
- StackWars::TextClient
- Defined in:
- lib/stack_wars/text_client.rb
Instance Method Summary collapse
-
#initialize(game) ⇒ TextClient
constructor
A new instance of TextClient.
- #play(string) ⇒ Object
Constructor Details
#initialize(game) ⇒ TextClient
Returns a new instance of TextClient.
3 4 5 |
# File 'lib/stack_wars/text_client.rb', line 3 def initialize(game) @game = game end |
Instance Method Details
#play(string) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/stack_wars/text_client.rb', line 7 def play(string) md = string.match(/^ *(?<pos1>\d+ +\d+) *(?<pos2>\d+ +\d+)? *$/) raise Errors::ParseError unless md if md[:pos2] @game.play(point(md[:pos1]), point(md[:pos2])) else @game.play(point(md[:pos1])) end end |