Class: Rubinstein::Runner

Inherits:
BasicObject
Includes:
Actions
Defined in:
lib/rubinstein/runner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Actions

included

Constructor Details

#initialize(world) ⇒ Runner

Returns a new instance of Runner.



14
15
16
# File 'lib/rubinstein/runner.rb', line 14

def initialize(world)
  @__world = world
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



32
33
34
# File 'lib/rubinstein/runner.rb', line 32

def method_missing(name,*args)
  return *args.flatten.unshift(name.to_s)
end

Instance Attribute Details

#__handledObject

Returns the value of attribute __handled.



12
13
14
# File 'lib/rubinstein/runner.rb', line 12

def __handled
  @__handled
end

#__worldObject

Returns the value of attribute __world.



12
13
14
# File 'lib/rubinstein/runner.rb', line 12

def __world
  @__world
end

Class Method Details

.const_missing(name) ⇒ Object



6
7
8
# File 'lib/rubinstein/runner.rb', line 6

def const_missing(name)
  Kernel.const_get(name)
end

Instance Method Details

#__execute(string) ⇒ Object



22
23
24
25
26
# File 'lib/rubinstein/runner.rb', line 22

def __execute(string)
  @__handled = false
  instance_eval(string)
  __puts "I don't understand" unless @__handled
end

#__handle!Object



18
19
20
# File 'lib/rubinstein/runner.rb', line 18

def __handle!
  @__handled = true
end

#__puts(message) ⇒ Object



28
29
30
# File 'lib/rubinstein/runner.rb', line 28

def __puts(message)
  $stdout.puts(message)
end

#look(*args) ⇒ Object



36
37
38
39
# File 'lib/rubinstein/runner.rb', line 36

def look(*args)
  __puts @__world.player.location.instance_eval(:@description)
  __handle!
end