Class: Gamefic::Scriptable::Proxy::Agent
- Inherits:
-
Object
- Object
- Gamefic::Scriptable::Proxy::Agent
- Defined in:
- lib/gamefic/scriptable/proxy.rb
Overview
The object that fetches a proxied entity.
Instance Attribute Summary collapse
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
Instance Method Summary collapse
- #fetch(container) ⇒ Object
-
#initialize(symbol) ⇒ Agent
constructor
A new instance of Agent.
Constructor Details
#initialize(symbol) ⇒ Agent
Returns a new instance of Agent.
13 14 15 |
# File 'lib/gamefic/scriptable/proxy.rb', line 13 def initialize symbol @symbol = symbol end |
Instance Attribute Details
#symbol ⇒ Object (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 |