Class: Input
- Inherits:
-
Object
- Object
- Input
- Defined in:
- lib/another_toy_robot/input.rb
Instance Method Summary collapse
- #basename ⇒ Object
-
#initialize(input) ⇒ Input
constructor
A new instance of Input.
- #params ⇒ Object
- #to_class ⇒ Object
Constructor Details
#initialize(input) ⇒ Input
Returns a new instance of Input.
9 10 11 |
# File 'lib/another_toy_robot/input.rb', line 9 def initialize(input) @input = input.strip.downcase end |
Instance Method Details
#basename ⇒ Object
13 14 15 |
# File 'lib/another_toy_robot/input.rb', line 13 def basename @basename ||= @input.split(" ").first end |
#params ⇒ Object
17 18 19 |
# File 'lib/another_toy_robot/input.rb', line 17 def params @params ||= @input.split(" ").drop 1 end |
#to_class ⇒ Object
21 22 23 24 25 |
# File 'lib/another_toy_robot/input.rb', line 21 def to_class klass = "#{basename.capitalize}Command" return InvalidCommand unless Object.const_defined? klass Object.const_get klass end |