another_toy_robot 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55f824721df20bab7fca05a862acfba15aa0be7b
4
- data.tar.gz: 97ee1296da13b1b7d3464c9ee3cb5c6c8d084dfb
3
+ metadata.gz: a5a18c13b931414726f5791b99bfcf99aebeef33
4
+ data.tar.gz: c90671becf561d669c715735dc429e2a29832047
5
5
  SHA512:
6
- metadata.gz: d02212f8b657911404346f3ba7cb10cc129dd2a5877a6b39339926f974b92dfea79f0ad06e566f562d539d6214e81e7db91627e20f365ea0e18926b5b08f7261
7
- data.tar.gz: a387500683a0e490d23c5bdaef8ad847388a6d0c723564f1842b0af8dbe8ee326090a0b35e18bb1eb9db2faff201022f756fb8ce004ac27ee1fafc8562f4f367
6
+ metadata.gz: 4d2f61536ae43ff3aaaec02c0cff2fab12bde726aa58dbdc5b5b0c95fa164c0dcd8b0bb8bbea87d90ddb20dda37548047d19bcfcf7430add2dfc261a4a1867fc
7
+ data.tar.gz: 139dfa912da0076ca7e0b47e8ef1aeebe45fb917ff8824e64afd6877f5723b4c73ad7015872c47f2acd4cbb8a2bd0e6942f89cbdf7ca30e5f5cee9c32b10a42f
@@ -10,6 +10,10 @@ class Client
10
10
  end
11
11
 
12
12
  def command_for(input)
13
- input.new_command(@robot).execute
13
+ klass = input.to_class
14
+ params = input.params
15
+ command = klass.new target: @robot, params: params
16
+
17
+ command.execute
14
18
  end
15
19
  end
@@ -10,21 +10,15 @@ class Input
10
10
  @input = input.strip.downcase
11
11
  end
12
12
 
13
- def new_command(target)
14
- command_class.new target: target, params: params
13
+ def basename
14
+ @basename ||= @input.split(" ").first
15
15
  end
16
16
 
17
- private
18
-
19
17
  def params
20
18
  @params ||= @input.split(" ").drop 1
21
19
  end
22
20
 
23
- def basename
24
- @basename ||= @input.split(" ").first
25
- end
26
-
27
- def command_class
21
+ def to_class
28
22
  klass = "#{basename.capitalize}Command"
29
23
  return InvalidCommand unless Object.const_defined? klass
30
24
  Object.const_get klass
@@ -1,3 +1,3 @@
1
1
  module AnotherToyRobot
2
- VERSION = "0.1.12".freeze
2
+ VERSION = "0.1.13".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: another_toy_robot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sheldon J. Johnson