Class: PBM::Interpreter

Inherits:
Object
  • Object
show all
Defined in:
lib/pbm/interpreter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInterpreter

Returns a new instance of Interpreter.



16
17
18
# File 'lib/pbm/interpreter.rb', line 16

def initialize
  @running = true
end

Instance Attribute Details

#commandsObject

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

Parameters:

  • value

    the value to set the attribute running to.



13
14
15
# File 'lib/pbm/interpreter.rb', line 13

def running=(value)
  @running = value
end

Class Method Details

.loadObject



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

Returns:

  • (Boolean)


26
27
28
# File 'lib/pbm/interpreter.rb', line 26

def running?
  !!@running
end