Class: PBM::Interpreter
- Inherits:
-
Object
- Object
- PBM::Interpreter
- Defined in:
- lib/pbm/interpreter.rb
Instance Attribute Summary collapse
-
#commands ⇒ Object
Returns the value of attribute commands.
-
#running ⇒ Object
writeonly
Sets the attribute running.
Class Method Summary collapse
Instance Method Summary collapse
- #exec(command) ⇒ Object
-
#initialize ⇒ Interpreter
constructor
A new instance of Interpreter.
- #running? ⇒ Boolean
Constructor Details
#initialize ⇒ Interpreter
Returns a new instance of Interpreter.
16 17 18 |
# File 'lib/pbm/interpreter.rb', line 16 def initialize @running = true end |
Instance Attribute Details
#commands ⇒ Object
Returns the value of attribute commands.
14 15 16 |
# File 'lib/pbm/interpreter.rb', line 14 def commands @commands end |
#running=(value) ⇒ Object (writeonly)
Sets the attribute running
13 14 15 |
# File 'lib/pbm/interpreter.rb', line 13 def running=(value) @running = value end |
Class Method Details
.load ⇒ Object
6 7 8 9 10 |
# File 'lib/pbm/interpreter.rb', line 6 def load self.new.tap do |interpreter| interpreter.commands = AllCommands.load(interpreter) end end |
Instance Method Details
#exec(command) ⇒ Object
20 21 22 23 24 |
# File 'lib/pbm/interpreter.rb', line 20 def exec command command = command.to_sym raise "#{command}: invalid command." unless @commands.has_key?(command) @commands[command].run end |
#running? ⇒ Boolean
26 27 28 |
# File 'lib/pbm/interpreter.rb', line 26 def running? !!@running end |