Class: Gamefic::Scriptable::Proxy::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/gamefic/scriptable/proxy.rb

Overview

The object that fetches a proxied entity.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol) ⇒ Agent

Returns a new instance of Agent.

Parameters:

  • symbol (Symbol, Integer)


13
14
15
# File 'lib/gamefic/scriptable/proxy.rb', line 13

def initialize symbol
  @symbol = symbol
end

Instance Attribute Details

#symbolObject (readonly)

Returns the value of attribute symbol.



10
11
12
# File 'lib/gamefic/scriptable/proxy.rb', line 10

def symbol
  @symbol
end

Instance Method Details

#fetch(container) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/gamefic/scriptable/proxy.rb', line 17

def fetch container
  if symbol.to_s =~ /^\d+$/
    Stage.run(container, symbol) { |sym| entities[sym] }
  elsif symbol.to_s.start_with?('@')
    Stage.run(container, symbol) { |sym| instance_variable_get(sym) }
  else
    Stage.run(container, symbol) { |sym| send(sym) }
  end
end